tuxmartin

python ws protobuff

Feb 18th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.41 KB | None | 0 0
  1. def on_message(ws, message):
  2.     print "Prisla data:"
  3.     print message
  4.     print "--------------"
  5.  
  6.     request = abstract_pb2.Request()
  7.     request = message
  8.     header = abstract_pb2.Header()
  9.  
  10.     print header.type
  11.     print ".................."
  12.  
  13.  
  14.     print request.data
  15.     print "_________________"
  16.  
  17.     if (header.type == "Text" ):
  18.         print "je to text"
  19.         #text = Text_pb2.Text()
  20.         #text.text = request.data
  21.         #print text.text
  22.  
  23.  
  24. # ----------------------------------------------- vystup (poslu si "abc"):
  25.  
  26. /usr/bin/python2.7 /home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF_abstract.py
  27. --- request header ---
  28. GET /ws/protobuf/75?access_token=67bde5/usr/bin/python2.7 /home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF_abstract.py
  29. --- request header ---
  30. GET /ws/protobuf/75?access_token=67bde5d1b5f14520a565d03deae877fb HTTP/1.1
  31. Upgrade: websocket
  32. Connection: Upgrade
  33. Host: 194.228.153.100:9000
  34. Origin: http://194.228.153.100:9000
  35. Sec-WebSocket-Key: e+CUcj7zS7+0/2cKGRXY+Q==
  36. Sec-WebSocket-Version: 13
  37. head2:value2
  38. head1:value1
  39.  
  40.  
  41. -----------------------
  42. --- response header ---
  43. HTTP/1.1 101 Switching Protocols
  44. Upgrade: websocket
  45. Connection: Upgrade
  46. Sec-WebSocket-Accept: ru7quF8dBgVZELkUbeD+OAI7mRE=
  47. -----------------------
  48. 'str' object has no attribute 'data'
  49.   File "/usr/lib/python2.7/dist-packages/websocket.py", line 872, in _callback
  50.     callback(self, *args)
  51.   File "/home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF_abstract.py", line 22, in on_message
  52.     print request.data
  53. Prisla data:
  54.  
  55. Text
  56. abc
  57. --------------
  58.  
  59. ..................d1b5f14520a565d03deae877fb HTTP/1.1
  60. Upgrade: websocket
  61. Connection: Upgrade
  62. Host: 194.228.153.100:9000
  63. Origin: http://194.228.153.100:9000
  64. Sec-WebSocket-Key: e+CUcj7zS7+0/2cKGRXY+Q==
  65. Sec-WebSocket-Version: 13
  66. head2:value2
  67. head1:value1
  68.  
  69.  
  70. -----------------------
  71. --- response header ---
  72. HTTP/1.1 101 Switching Protocols
  73. Upgrade: websocket
  74. Connection: Upgrade
  75. Sec-WebSocket-Accept: ru7quF8dBgVZELkUbeD+OAI7mRE=
  76. -----------------------
  77. 'str' object has no attribute 'data'
  78.   File "/usr/lib/python2.7/dist-packages/websocket.py", line 872, in _callback
  79.     callback(self, *args)
  80.   File "/home/martin/PycharmProjects/MEO_kamera/wsMEOcallbackPROTOBUFF_abstract.py", line 22, in on_message
  81.     print request.data
  82. Prisla data:
  83.  
  84. Text
  85. abc
  86. --------------
  87.  
  88. ..................
Advertisement
Add Comment
Please, Sign In to add comment