forked from Lawouach/WebSocket-for-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Lawouach#167 hopefully by reading the internal SSL socket object'…
…s buffer
- Loading branch information
Showing
4 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
def run_threaded(): | ||
from ws4py.client.threadedclient import WebSocketClient | ||
class EchoClient(WebSocketClient): | ||
def opened(self): | ||
self.send("hello") | ||
|
||
def closed(self, code, reason=None): | ||
print(("Closed down", code, reason)) | ||
|
||
def received_message(self, m): | ||
print(m) | ||
self.close() | ||
|
||
try: | ||
ws = EchoClient('wss://localhost:9000/ws') | ||
ws.connect() | ||
ws.run_forever() | ||
except KeyboardInterrupt: | ||
ws.close() | ||
|
||
def run_tornado(): | ||
from tornado import ioloop | ||
from ws4py.client.tornadoclient import TornadoWebSocketClient | ||
class MyClient(TornadoWebSocketClient): | ||
def opened(self): | ||
self.send("hello") | ||
|
||
def closed(self, code, reason=None): | ||
print(("Closed down", code, reason)) | ||
ioloop.IOLoop.instance().stop() | ||
|
||
def received_message(self, m): | ||
print(m) | ||
self.close() | ||
|
||
ws = MyClient('wss://localhost:9000/ws') | ||
ws.connect() | ||
|
||
ioloop.IOLoop.instance().start() | ||
|
||
def run_gevent(): | ||
from gevent import monkey; monkey.patch_all() | ||
import gevent | ||
from ws4py.client.geventclient import WebSocketClient | ||
|
||
ws = WebSocketClient('wss://localhost:9000/ws') | ||
ws.connect() | ||
|
||
ws.send("hello") | ||
|
||
def incoming(): | ||
while True: | ||
m = ws.receive() | ||
if m is not None: | ||
print(m) | ||
else: | ||
break | ||
|
||
ws.close() | ||
|
||
gevent.joinall([gevent.spawn(incoming)]) | ||
|
||
#run_gevent() | ||
run_threaded() | ||
run_tornado() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters