- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / third_party / websocket-client / README.rst
1 =================
2 websocket-client
3 =================
4
5 websocket-client module  is WebSocket client for python. This provide the low level APIs for WebSocket. All APIs are the synchronous functions.
6
7 websocket-client supports only hybi-13.
8
9 License
10 ============
11
12  - LGPL
13
14 Installation
15 =============
16
17 This module is tested on only Python 2.7.
18
19 Type "python setup.py install" or "pip install websocket-client" to install.
20
21 This module does not depend on any other module.
22
23 Example
24 ============
25
26 Low Level API example::
27
28     from websocket import create_connection
29     ws = create_connection("ws://echo.websocket.org/")
30     print "Sending 'Hello, World'..."
31     ws.send("Hello, World")
32     print "Sent"
33     print "Reeiving..."
34     result =  ws.recv()
35     print "Received '%s'" % result
36     ws.close()
37
38
39 JavaScript websocket-like API example::
40
41   import websocket
42   import thread
43   import time
44   
45   def on_message(ws, message):
46       print message
47   
48   def on_error(ws, error):
49       print error
50   
51   def on_close(ws):
52       print "### closed ###"
53   
54   def on_open(ws):
55       def run(*args):
56           for i in range(3):
57               time.sleep(1)
58               ws.send("Hello %d" % i)
59           time.sleep(1)
60           ws.close()
61           print "thread terminating..."
62       thread.start_new_thread(run, ())
63   
64   
65   if __name__ == "__main__":
66       websocket.enableTrace(True)
67       ws = websocket.WebSocketApp("ws://echo.websocket.org/",
68                                   on_message = on_message,
69                                   on_error = on_error,
70                                   on_close = on_close)
71       ws.on_open = on_open
72       
73       ws.run_forever()
74
75
76 wsdump.py
77 ============
78
79 wsdump.py is simple WebSocket test(debug) tool.
80
81 sample for echo.websocket.org::
82
83   $ wsdump.py ws://echo.websocket.org/
84   Press Ctrl+C to quit
85   > Hello, WebSocket
86   < Hello, WebSocket
87   > How are you?
88   < How are you?
89
90 Usage
91 ---------
92
93 usage::
94   wsdump.py [-h] [-v [VERBOSE]] ws_url
95
96 WebSocket Simple Dump Tool
97
98 positional arguments:
99   ws_url                websocket url. ex. ws://echo.websocket.org/
100
101 optional arguments:
102   -h, --help                           show this help message and exit
103
104   -v VERBOSE, --verbose VERBOSE    set verbose mode. If set to 1, show opcode. If set to 2, enable to trace websocket module
105
106 example::
107
108   $ wsdump.py ws://echo.websocket.org/
109   $ wsdump.py ws://echo.websocket.org/ -v
110   $ wsdump.py ws://echo.websocket.org/ -vv
111
112 ChangeLog
113 ============
114
115 - v0.7.0
116
117   - fixed problem to read long data.(ISSUE#12)
118   - fix buffer size boundary violation
119
120 - v0.6.0
121
122   - Patches: UUID4, self.keep_running, mask_key (ISSUE#11)
123   - add wsdump.py tool 
124
125 - v0.5.2
126
127   - fix Echo App Demo Throw Error: 'NoneType' object has no attribute 'opcode  (ISSUE#10)
128
129 - v0.5.1
130
131   - delete invalid print statement.
132
133 - v0.5.0
134
135   - support hybi-13 protocol.
136
137 - v0.4.1
138
139   - fix incorrect custom header order(ISSUE#1)
140