tuxmartin

Untitled

Feb 13th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1.  
  2. import websocket
  3.  
  4. from protobuf import test_pb2
  5.  
  6. def on_message(ws, message):
  7.     print "Prisla data:"
  8.     print message
  9.  
  10.     test = test_pb2.Test()
  11.     test.name = message
  12.     print test.name
  13.  
  14. def on_error(ws, error):
  15.     print error
  16.  
  17. def on_close(ws):
  18.     print "### closed ###"
  19.  
  20. def on_open(ws):
  21.     def run(*args):
  22.         print "Start..."
  23.  
  24.     #thread.start_new_thread(run, ())
  25.  
  26.  
  27. if __name__ == "__main__":
  28.     websocket.enableTrace(True)
  29.     ws = websocket.WebSocketApp("ws://194.228.153.100:9000/ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb",
  30.                               on_message = on_message,
  31.                               on_error = on_error,
  32.                               on_close = on_close)
  33.     ws.on_open = on_open
  34.     ws.run_forever()
  35.  
  36.  
  37. # ------------------------------------------------
  38. /usr/bin/python2.7 /home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF.py
  39. --- request header ---
  40. GET /ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb HTTP/1.1
  41. Upgrade: websocket
  42. Connection: Upgrade
  43. Host: 194.228.153.100:9000
  44. Origin: http://194.228.153.100:9000
  45. Sec-WebSocket-Key: CkkiabCnQWWAJwfhWX+NtA==
  46. Sec-WebSocket-Version: 13
  47.  
  48.  
  49. -----------------------
  50. --- response header ---
  51. HTTP/1.1 101 Switching Protocols
  52. Upgrade: websocket
  53. Connection: Upgrade
  54. Sec-WebSocket-Accept: N2fr4BnYJKh7udH7FkgGYk+Kh3Y=
  55. -----------------------
  56. Prisla data:
  57.  
  58. testovaci_zprava
  59.  
  60. testovaci_zprava
Advertisement
Add Comment
Please, Sign In to add comment