You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ws4py tries hard to be as conformant as it can to the specification. In order to validate this conformance, each release is run against the Autobahn testsuite (http://autobahn.ws/) which provides an extensive converage of various aspects of the protocol.
167
-
168
-
You will require the Autobahn test suite:
169
-
170
-
```
171
-
$ pip install autobahntestsuite
172
-
```
173
-
174
-
In order to test the conformance of ws4py along other Python implementations, namely Autobahn 0.5+ and Tornado, run the followings:
175
-
176
-
```
177
-
$ cd test
178
-
$ python autobahn_test_servers.py --run-all
179
-
```
180
-
181
-
Next, run the Autobahn test suite from the ws4py test directory:
182
-
183
-
```
184
-
$ wstest -m fuzzingclient -s fuzzingclient.json
185
-
```
186
-
187
-
Once the tests have finished, reports will be available from ```test/reports/servers```.
188
-
189
-
Online test reports can be found at: http://www.defuze.org/oss/ws4py/testreports/servers/
190
-
191
-
Browser Support
192
-
---------------
193
-
194
-
ws4py has been tested using:
195
-
196
-
* Chromium 22
197
-
* Firefox 16
198
-
199
-
Since Safari, Opera and IE do not yet support the protocol or the RFC's version, ws4py won't
200
-
work with them. See http://caniuse.com/websockets for reference.
201
-
202
-
Bear in mind that time is a premium and maintaining obsolete and unsecure protocols is not
203
-
one of ws4py's goals. It's therefore unlikely it will ever support them.
204
-
205
-
Examples
206
-
--------
207
-
208
-
ws4py comes with a few examples:
209
-
210
-
* The ```echo_cherrypy_server``` example provides a simple Echo server. It requires CherryPy 3.2.2.
211
-
Open a couple of tabs pointing at http://localhost:9000 and chat accross those tables.
212
-
* The ```droid_sensor_cherrypy_server``` broadcasts sensor metrics to clients. Point your browser to http://localhost:9000
213
-
Then run the ```droid_sensor``` module from your Android device using SL4A.
214
-
A screenshot of what this renders to: http://www.defuze.org/oss/ws4py/screenshots/droidsensors.png
215
-
You will find a lovely video of this demo in action at https://www.youtube.com/watch?v=baD-rShmZcM. Thanks to Mat Bettinson for this.
216
-
217
-
Credits
218
-
-------
219
-
220
-
Many thanks to the pywebsocket and Tornado projects which have provided a good base to write ws4py.
221
-
Thanks also to Jeff Lindsay (progrium) for the gevent server support.
222
-
A well deserved thank you to Tobias Oberstein for his websocket test suite: https://github.com/oberstet/Autobahn
6
+
Read the `documentation <https://ws4py.readthedocs.org/en/latest/>`_ for more information
Copy file name to clipboardExpand all lines: docs/sources/maintainer/design.rst
+21Lines changed: 21 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,9 @@
3
3
Design
4
4
======
5
5
6
+
Workflow
7
+
--------
8
+
6
9
ws4py's design is actually fairly simple and straigtforward. At a high level this is what is going on:
7
10
8
11
.. seqdiag::
@@ -37,4 +40,22 @@ which is passed on to the global ws4py :class:`ws4py.manager.WebSocketManager` i
37
40
Most notably, the manager will poll for the socket's receive events so that, when bytes are available,
38
41
the websocket object can read and process them.
39
42
43
+
Implementation
44
+
--------------
45
+
46
+
ws4py data model is rather simple and follows the protocol itself:
47
+
48
+
a highlevel WebSocket class that determines actions to carry based on messages that are parsed.
49
+
a Stream class that handles a single message at a time
50
+
a Frame class that performs the low level protocol parsing of frames
51
+
Each are inter-connected as russian dolls generators. The process heavily relies on the capacity to send to a generator. So everytime one of those layers requires something, it yields and then its holder sends it back whatever was required.
52
+
53
+
The Frame parser yields the number of bytes it needs at any time, the stream parser forwards it back to the WebSocket class which gets data from the underlying data provider it holds a reference to (a socket typically). The WebSocket class sends bytes as they are read from the socket down to the stream parser which forwards them to the frame parser.
54
+
55
+
Eventually a frame is parsed and handled by the stream parser which in turns yields a complete message made of all parsed frames.
56
+
57
+
The interesting aspect here is that the socket provider is totally abstracted from the protocol implementation which simply requires bytes as they come.
58
+
59
+
This means one could write a ws4py socket provider that doesn't read from the wire but from any other source.
0 commit comments