Last active
August 29, 2015 14:06
-
-
Save Zaharid/7d9288cdd162ba684166 to your computer and use it in GitHub Desktop.
Minimun websocket client for 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
from tornado.websocket import websocket_connect | |
from tornado import ioloop | |
from tornado import gen | |
@gen.coroutine | |
def onconnect(future): | |
ws = future.result() | |
while 1: | |
m = input("message?\n") | |
ws.write_message(m) | |
msg = yield ws.read_message() | |
print(msg) | |
if __name__ == '__main__': | |
future = websocket_connect('ws://localhost:8888/ws',callback = onconnect) | |
ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment