Comments (9)
I think it's fine to ignore this for draft 76 for now. I'm not sure
how long it will take me to implement RFC 6455, but I'll add the
handshake parsing in there. Eventually, we should switch completely
to RFC 6455, and remove support for draft 76.
On Sun, May 6, 2012 at 8:40 PM, Takafumi Arakaki
[email protected]
wrote:
See: http://dev.w3.org/html5/websockets/#the-websocket-interface
Problem is that you will need to parse handshake reply from server. I think implementing handshake parser for current supported version (draft 76) is useless as it is old. Do you think we should wait until RFC 6455 implementation (#1) is finished? For now, I am working around this problem simply sleep after connecting server and call "onopen" function.
Reply to this email directly or view it on GitHub:
#7
from emacs-websocket.
Yeah, I agree with you about completely switching to RFC 6455.
from emacs-websocket.
When we switch to RFC 6455, how about changing API also to follow W3C? I think this makes easier to understand API, especially for programmers who use javascript. Something like this:
(defstruct websocket
;; -- Internal variables
(conn (assert nil) :read-only t)
(inflight-packet nil)
;; -- Attributes defined in W3C API
(url (assert nil) :read-only t)
(ready-state nil)
;; callbacks
(on-open (assert nil) :read-only t)
(on-error (assert nil)) ; It should be OK to re-define
(on-close (assert nil)) ; these attributes after opening
(on-message (assert nil)) ; socket, no?
;; arguments for callbacks
(on-open-args (assert nil) :read-only t)
(on-error-args (assert nil))
(on-close-args (assert nil))
(on-message-args (assert nil)))
I am not sure having all these on-EVENT-args
is a good choice. Other alternatives I can think of:
- Make
on-EVENT
slot hold cons(FUNCTION . ARGS)
and callback is called as(apply FUNCTION packet ARGS)
. - Add miscellaneous slot to websocket and callback is called as
(funcall FUNCTION packet websocket)
. - Add
MAKE-WEBSOCKET
argument (default value is'make-websocket
) towebsocket-open
and callback is called as(funcall FUNCTION packet websocket)
. This way, user can extend websocekt struct and put stuff he wants to hold in his extra slot. - Forget about arguments. Use
lexical-let
.
Also, how about changing prefix to websocket-client
from websocket
? Maybe we want to have websocket server at some point.
from emacs-websocket.
This is a good suggestion, thanks! I probably will get to this after
the current set of changes I'm doing on the frame protocol. I think I
like the lexical-let version the best. We can also make sure that the
websocket callbacks all happen in the context of a buffer, and have
that be the only "argument". The client can then use buffer-local
variables. Let me think about this, but in general your idea sounds
good and I'll implement it like the w3c spec in the near future.
On Sat, May 19, 2012 at 2:31 PM, Takafumi Arakaki
[email protected]
wrote:
When we switch to RFC 6455, how about changing API also to follow W3C? I think this makes easier to understand API, especially for programmers who use javascript. Something like this:
(defstruct websocket ;; -- Internal variables (conn (assert nil) :read-only t) (inflight-packet nil) ;; -- Attributes defined in W3C API (url (assert nil) :read-only t) (ready-state nil) ;; callbacks (on-open (assert nil) :read-only t) (on-error (assert nil)) ; It should be OK to re-define (on-close (assert nil)) ; these attributes after opening (on-message (assert nil)) ; socket, no? ;; arguments for callbacks (on-open-args (assert nil) :read-only t) (on-error-args (assert nil)) (on-close-args (assert nil)) (on-message-args (assert nil)))I am not sure having all these
on-EVENT-args
is a good choice. Other alternatives I can think of:
- Make
on-EVENT
slot hold cons(FUNCTION . ARGS)
and callback is called as(apply FUNCTION packet ARGS)
.- Add miscellaneous slot to websocket and callback is called as
(funcall FUNCTION packet websocket)
.- Add
MAKE-WEBSOCKET
argument (default value is'make-websocket
) towebsocket-open
and callback is called as(funcall FUNCTION packet websocket)
. This way, user can extend websocekt struct and put stuff he wants to hold in his extra slot.- Forget about arguments. Use
lexical-let
.Also, how about changing prefix to
websocket-client
fromwebsocket
? Maybe we want to have websocket server at some point.
Reply to this email directly or view it on GitHub:
#7 (comment)
from emacs-websocket.
BTW, about changing websocket to websocket-client - yes, it's a good
idea, but the name is long, and given how we'll have to prefix
everything by this name, I wonder if we should instead use ws-client
or something like that. This is something we should do later, I
think.
On Sat, May 19, 2012 at 7:27 PM, Andrew Hyatt [email protected] wrote:
This is a good suggestion, thanks! I probably will get to this after
the current set of changes I'm doing on the frame protocol. I think I
like the lexical-let version the best. We can also make sure that the
websocket callbacks all happen in the context of a buffer, and have
that be the only "argument". The client can then use buffer-local
variables. Let me think about this, but in general your idea sounds
good and I'll implement it like the w3c spec in the near future.On Sat, May 19, 2012 at 2:31 PM, Takafumi Arakaki
[email protected]
wrote:When we switch to RFC 6455, how about changing API also to follow W3C? I think this makes easier to understand API, especially for programmers who use javascript. Something like this:
(defstruct websocket ;; -- Internal variables (conn (assert nil) :read-only t) (inflight-packet nil) ;; -- Attributes defined in W3C API (url (assert nil) :read-only t) (ready-state nil) ;; callbacks (on-open (assert nil) :read-only t) (on-error (assert nil)) ; It should be OK to re-define (on-close (assert nil)) ; these attributes after opening (on-message (assert nil)) ; socket, no? ;; arguments for callbacks (on-open-args (assert nil) :read-only t) (on-error-args (assert nil)) (on-close-args (assert nil)) (on-message-args (assert nil)))I am not sure having all these
on-EVENT-args
is a good choice. Other alternatives I can think of:
- Make
on-EVENT
slot hold cons(FUNCTION . ARGS)
and callback is called as(apply FUNCTION packet ARGS)
.- Add miscellaneous slot to websocket and callback is called as
(funcall FUNCTION packet websocket)
.- Add
MAKE-WEBSOCKET
argument (default value is'make-websocket
) towebsocket-open
and callback is called as(funcall FUNCTION packet websocket)
. This way, user can extend websocekt struct and put stuff he wants to hold in his extra slot.- Forget about arguments. Use
lexical-let
.Also, how about changing prefix to
websocket-client
fromwebsocket
? Maybe we want to have websocket server at some point.
Reply to this email directly or view it on GitHub:
#7 (comment)
from emacs-websocket.
I guess you are planning to start versioning after changing protocol, but please make sure do it before changing API! :)
About using buffer as "argument", I am not sure if it is a good idea because you can think of an application which has multiple buffers sharing connection. Making a special buffer for holding connection sounds a little bit redundant.
Emacs lisp functions seem to take callback argument usually. For example, run-at-time
, run-with-idle-timer
, url-retrieve
and make-network-process
. I agree that having all these on-EVENT-args
slots is not cool. I'd go with "packing by cons" or "miscellaneous slot" idea.
BTW, If you go with "miscellaneous slot" idea, probably the callback must be called via (funcall FUNCTION websocket packet)
. In this way, we can think like FUNCTION
is "overriding" default callback function, like Python method takes self
(=websocket
) as the first argument.
About websocket-client
, yea, I know it's too long. I hope Emacs has much more sophisticated name space management... One thing we can do is to use EIEIO and use same function name for server and client.
from emacs-websocket.
Sorry, I didn't understand what you mean by "versioning" here? My
plan is to finish all the receiving & sending code (should take me
another few days), make sure everything actually works in practice,
then I'll probably merge it back to the master branch.
I may or may not want to change the API in this branch. One one hand,
the API should be distinct from the protocol. But, actually, I'm
unsure this is the case. Right now I've already started passing the
websocket frame itself, instead of just the frame payload. The issue
is that I think I need to pass in whether the frame is a continuation
frame or not. The W3C API doesn't seem to deal with this, but
according to the spec it might be important, depending on what
extensions are used.
On Sat, May 19, 2012 at 8:26 PM, Takafumi Arakaki
[email protected]
wrote:
I guess you are planning to start versioning after changing protocol, but please make sure do it before changing API! :)
About using buffer as "argument", I am not sure if it is a good idea because you can think of an application which has multiple buffers sharing connection. Making a special buffer for holding connection sounds a little bit redundant.
Emacs lisp functions seem to take callback argument usually. For example,
run-at-time
,run-with-idle-timer
,url-retrieve
andmake-network-process
. I agree that having all theseon-EVENT-args
slots is not cool. I'd go with "packing by cons" or "miscellaneous slot" idea.BTW, If you go with "miscellaneous slot" idea, probably the callback must be called via
(funcall FUNCTION websocket packet)
. In this way, we can think likeFUNCTION
is "overriding" default callback function, like Python method takesself
(=websocket
) as the first argument.About
websocket-client
, yea, I know it's too long. I hope Emacs has much more sophisticated name space management... One thing we can do is to use EIEIO and use same function name for server and client.
Reply to this email directly or view it on GitHub:
#7 (comment)
from emacs-websocket.
Sorry, I didn't understand what you mean by "versioning" here?
Sorry, I was not clear. I mean to release websocket.el and attach a version number to that release; add websocket-version
variable, add tag in the git repository and maybe put in marmalade.
I may or may not want to change the API in this branch.
Yes, I think it's better to do it after merge this in master, probably in a separate branch again.
I am OK with extra/different arguments. Maybe we can just use the function/attribute naming of the W3C API.
from emacs-websocket.
I'm closing this as fixed, but I made the W3C compliance another issue, which is next on my list of things to do.
from emacs-websocket.
Related Issues (20)
- websocket-frame-text error HOT 1
- Add release tags HOT 3
- Custom headers in handshake HOT 4
- How to handle an error occured in `websocket-outer-filter`? HOT 6
- A single message ws.send(data); comes in as two messages HOT 5
- Speed feedback HOT 10
- Randomly losing connections under emacs-ipython-notebook with version 1.11 HOT 5
- Error (websocket): in callback `on-message': JSON readtable error HOT 4
- Setting case-fold-search to nil results "Incorrect handhake from websocket" error HOT 7
- declares GPL-3+, but provided full-text license is GPL-2+ HOT 3
- Please tag a 1.12 release HOT 1
- Please consider adapting websocket-functional-test.el to use ert-deftest HOT 12
- TLSv1.3 HOT 1
- Branch rename breaks package installation HOT 6
- websocket-test.el: ‘flet’ is an obsolete macro (as of [emacs] 24.3) HOT 3
- websocket-to-bytes signal type error HOT 8
- Support connecting through proxies HOT 7
- infinite failure loop - emacs locked up HOT 18
- error 403 with ein over proxy HOT 14
- Push to ELPA? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emacs-websocket.