forked from TheWaWaR/python-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws_test.py
More file actions
34 lines (26 loc) · 808 Bytes
/
Copy pathws_test.py
File metadata and controls
34 lines (26 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from ws4py.client.threadedclient import WebSocketClient
import time
class DummyClient(WebSocketClient):
def opened(self):
def data_provider():
for i in range(1, 200, 25):
yield "#" * i
self.send(data_provider())
for i in range(0, 200, 25):
print i
self.send("*" * i)
def closed(self, code, reason):
print "Closed down", code, reason
def received_message(self, m):
print "=> %d %s" % (len(m), str(m))
if len(str(m)) == 175:
self.close(reason='Bye bye')
if __name__ == '__main__':
try:
ws = DummyClient('ws://localhost:9000/')
ws.connect()
print 'connected'
time.sleep(60)
except KeyboardInterrupt:
ws.close()
print 'The END'