Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import websocket
- from protobuf import test_pb2
- def on_message(ws, message):
- print "Prisla data:"
- print message
- test = test_pb2.Test()
- test.name = message
- print test.name
- def on_error(ws, error):
- print error
- def on_close(ws):
- print "### closed ###"
- def on_open(ws):
- def run(*args):
- print "Start..."
- #thread.start_new_thread(run, ())
- if __name__ == "__main__":
- websocket.enableTrace(True)
- ws = websocket.WebSocketApp("ws://194.228.153.100:9000/ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb",
- on_message = on_message,
- on_error = on_error,
- on_close = on_close)
- ws.on_open = on_open
- ws.run_forever()
- # ------------------------------------------------
- /usr/bin/python2.7 /home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF.py
- --- request header ---
- GET /ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb HTTP/1.1
- Upgrade: websocket
- Connection: Upgrade
- Host: 194.228.153.100:9000
- Origin: http://194.228.153.100:9000
- Sec-WebSocket-Key: CkkiabCnQWWAJwfhWX+NtA==
- Sec-WebSocket-Version: 13
- -----------------------
- --- response header ---
- HTTP/1.1 101 Switching Protocols
- Upgrade: websocket
- Connection: Upgrade
- Sec-WebSocket-Accept: N2fr4BnYJKh7udH7FkgGYk+Kh3Y=
- -----------------------
- Prisla data:
- testovaci_zprava
- testovaci_zprava
Advertisement
Add Comment
Please, Sign In to add comment