#!/usr/bin/python
#
import sys
import json
import datetime
import time
from ws4py.client.threadedclient import WebSocketClient


class DummyClient(WebSocketClient):
    def opened(self):
        senddata = {'func': 'auth',
                    'param': {'token': 'abcdefgh'}
                    }
        self.send(json.dumps(senddata))
        print(senddata)

    def closed(self, code, reason):
        print "Closed down", code, reason

    def received_message(self, m):
        print "=> %d %s" % (len(m), str(m))
        if len(str(m)) == 175:
            self.close(reason='Bye bye')

    def sendmsg(self):
        _seq = 1000

        senddata = {'func': 'broadcast_msg',
                    'param': {'markertype': 'testobject1', 
                              'markerlist': [
                    {'id': _seq,
                     'create_dt':  datetime.datetime.now().isoformat(),
                     'update_dt':  datetime.datetime.now().isoformat(),
                     'name': 'object%d' % (_seq),
                     'x': '142.370',
                     'y': '43.765',
                     'auther': 'dictoss',
                     'desc': 'test messge'}
                    ]
                              }
                    }
        self.send(json.dumps(senddata))
        print(senddata)


def main():
    try:
        ws = DummyClient('ws://192.168.22.102:8888/',
                         protocols=['http-only', 'chat'])
        ws.connect()

        while True:
            line = raw_input()
            print("stdin!")
            ws.sendmsg()

    except KeyboardInterrupt:
        ws.close()
        return 0
    except:
        print("EXCEPT: %s" % sys.exc_info()[1])
        return 1


if __name__ == '__main__':
    ret = main()
    sys.exit(ret)

@@ -12,16 +12,38 @@
 python%0A#
+ -*- coding: utf-8 -*-
 %0Aimport 
@@ -425,17 +425,18 @@
    print
- 
+((
 %22Closed 
@@ -454,16 +454,18 @@
 , reason
+))
 %0A%0A    de
@@ -506,17 +506,18 @@
    print
- 
+((
 %22=%3E %25d %25
@@ -537,16 +537,18 @@
  str(m))
+))
 %0A       
@@ -732,16 +732,41 @@
 aram': %7B
+%0A                        
 'markert
@@ -789,14 +789,9 @@
 t1',
- %0A    
+%0A
     
@@ -806,26 +806,24 @@
             
-  
 'markerlist'
@@ -846,16 +846,24 @@
         
+        
 %7B'id': _
@@ -888,16 +888,24 @@
         
+     
+   
 'create_
@@ -939,32 +939,40 @@
 ().isoformat(),%0A
+        
                 
@@ -1048,16 +1048,24 @@
         
+    
+    
 'name': 
@@ -1106,16 +1106,24 @@
         
+        
 'x': '14
@@ -1151,16 +1151,24 @@
         
+   
+     
 'y': '43
@@ -1174,16 +1174,24 @@
 3.765',%0A
+        
         
@@ -1245,16 +1245,24 @@
         
+  
+      
 'desc': 
@@ -1299,20 +1299,15 @@
     
- %5D%0A
      
-    
+%5D%0A
     
@@ -1318,31 +1318,26 @@
             
- 
 %7D%0A
-    
             
@@ -1372,32 +1372,41 @@
 .dumps(senddata)
+.encode()
 )%0A        print(
@@ -1615,17 +1615,26 @@
 e = 
-raw_input
+sys.stdin.readline
 ()%0A 
@@ -1778,16 +1778,17 @@
   print(
+(
 %22EXCEPT:
@@ -1812,16 +1812,17 @@
 fo()%5B1%5D)
+)
 %0A       

support python2 and python3.