tuxmartin

python ws protobuff

Feb 18th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. def on_message(ws, message):
  2.     print "Prisla data:"
  3.     #print message
  4.  
  5.     request = abstract_pb2.Request()
  6.     header = abstract_pb2.Header()
  7.  
  8.     request.ParseFromString(message)
  9.     print request.data
  10.  
  11.     if (header.type == "Test" ):
  12.         test = test_pb2.Test()
  13.         test.name = message
  14.         print test.name
  15.  
  16.  
  17. # -------------------------------- po spusteni a poslani dat "abc":
  18.  
  19. /usr/bin/python2.7 /home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF_abstract.py
  20. --- request header ---
  21. GET /ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb HTTP/1.1
  22. Upgrade: websocket
  23. Connection: Upgrade
  24. Host: 194.228.153.100:9000
  25. Origin: http://194.228.153.100:9000
  26. Sec-WebSocket-Key: hdcLj9FCQ5+apyb7oQW35g==
  27. Sec-WebSocket-Version: 13
  28. head2:value2
  29. head1:value1
  30.  
  31.  
  32. -----------------------
  33. --- response header ---
  34. HTTP/1.1 101 Switching Protocols
  35. Upgrade: websocket
  36. Connection: Upgrade
  37. Sec-WebSocket-Accept: eAqTkqnkuiGgBeJU8aY68MGLR00=
  38. -----------------------
  39. Prisla data:
  40.  
  41. abc
Advertisement
Add Comment
Please, Sign In to add comment