def heart_beat(self): msg = { 'uid' : 911, } cmd = 1001 pack_msg = tcp_pack_helper.pack_msg(cmd, json_helper.dumps(msg)) self.transport.write(pack_msg)
def heart_beat(self): msg = { 'uid': 911, } cmd = 1001 pack_msg = tcp_pack_helper.pack_msg(cmd, json_helper.dumps(msg)) self.transport.write(pack_msg)
def connectionMade(self): ''' 客户端连接成功之后会自动调用该方法 :return: ''' print 'is already connect to the server' msg = { 'uid' : 911, 'pwd' : 'dkjfkdjfkdjfkd', } cmd = 1000 #定义1000表示登陆 pack_msg = tcp_pack_helper.pack_msg(cmd, json_helper.dumps(msg)) self.transport.write(pack_msg) t = task.LoopingCall(self.heart_beat) t.start(10, now=True)
def connectionMade(self): ''' 客户端连接成功之后会自动调用该方法 :return: ''' print 'is already connect to the server' msg = gps_helper.read() #msg = { # 'uid' : 911, # 'pwd' : 'dkjfkdjfkdjfkd', #} cmd = 1000 #定义1000表示登陆 pack_msg = tcp_pack_helper.pack_msg( cmd, json_helper.dumps(gps_helper.read())) t = task.LoopingCall(self.heart_beat) t2 = task.LoopingCall(self.transport.write(pack_msg)) t.start(10, now=True) t2.start(2, now=True)