1
This commit is contained in:
parent
557fef4791
commit
977d5f4279
@ -203,7 +203,9 @@ void MSConn::ReportServerInfo()
|
||||
|
||||
void MSConn::OnConnectSync()
|
||||
{
|
||||
|
||||
CheckAlive();
|
||||
SyncIMServerList();
|
||||
ReportServerInfo();
|
||||
}
|
||||
|
||||
void MSConn::OnDisconnectSync()
|
||||
|
@ -26,7 +26,7 @@ def main():
|
||||
accounts = options.accounts.split(',')
|
||||
accounts = []
|
||||
for i in range(1):
|
||||
accounts.append('test' + str(i))
|
||||
accounts.append('testa' + str(i))
|
||||
for account in accounts:
|
||||
ioloop.IOLoop.current().spawn_callback(createVirtualClient, account, ws_url)
|
||||
|
||||
|
@ -27,6 +27,7 @@ class VirtualClient(object):
|
||||
def __init__(self, ws_url, account):
|
||||
self.ws_url = ws_url
|
||||
self.account = account
|
||||
self.recv_buf = bytearray()
|
||||
print(self.ws_url)
|
||||
|
||||
@gen.coroutine
|
||||
@ -81,27 +82,26 @@ class VirtualClient(object):
|
||||
msg = cs_proto_pb2.CMFriendApplyList()
|
||||
self.sendMsg(conn, msg)
|
||||
|
||||
def parsePacket(self, conn, recv_buf):
|
||||
while len(recv_buf) >= 8:
|
||||
pktlen = recv_buf[0] + (recv_buf[1] << 8)
|
||||
msgid = recv_buf[2] + (recv_buf[3] << 8)
|
||||
seqid = recv_buf[4] + \
|
||||
(recv_buf[5] << 8) + \
|
||||
(recv_buf[6] << 16) + \
|
||||
(recv_buf[7] << 24)
|
||||
sign = recv_buf[8] + (recv_buf[9] << 8)
|
||||
resv = recv_buf[10] + (recv_buf[11] << 8)
|
||||
if len(recv_buf) >= 12 + pktlen:
|
||||
msgbody = recv_buf[12 : 12 + pktlen]
|
||||
def parsePacket(self, conn):
|
||||
while len(self.recv_buf) >= 8:
|
||||
pktlen = self.recv_buf[0] + (self.recv_buf[1] << 8)
|
||||
msgid = self.recv_buf[2] + (self.recv_buf[3] << 8)
|
||||
seqid = self.recv_buf[4] + \
|
||||
(self.recv_buf[5] << 8) + \
|
||||
(self.recv_buf[6] << 16) + \
|
||||
(self.recv_buf[7] << 24)
|
||||
sign = self.recv_buf[8] + (self.recv_buf[9] << 8)
|
||||
resv = self.recv_buf[10] + (self.recv_buf[11] << 8)
|
||||
if len(self.recv_buf) >= 12 + pktlen:
|
||||
msgbody = self.recv_buf[12 : 12 + pktlen]
|
||||
self.onReceiveUserPacket(conn, msgid, msgbody)
|
||||
recv_buf = recv_buf[12 + pktlen:]
|
||||
self.recv_buf = self.recv_buf[12 + pktlen:]
|
||||
|
||||
def onReceiveUserPacket(self, conn, msgid, msgbody):
|
||||
try:
|
||||
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'), msgid)
|
||||
print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'), msgid, len(msgbody))
|
||||
msg = getSMMsg(msgid)
|
||||
ret = msg.ParseFromString(msgbody)
|
||||
print(len(msgbody))
|
||||
print(time.time(), time.strftime('[%H:%M:%S]'), msg.DESCRIPTOR.name + '{')
|
||||
print(str(msg), end='')
|
||||
print('}')
|
||||
@ -111,14 +111,13 @@ class VirtualClient(object):
|
||||
|
||||
@gen.coroutine
|
||||
def co_receiveMessage(self, conn):
|
||||
recv_buf = bytearray()
|
||||
while True:
|
||||
data = yield conn.read_message()
|
||||
if data is None:
|
||||
break
|
||||
else:
|
||||
recv_buf += data
|
||||
self.parsePacket(conn, recv_buf)
|
||||
self.recv_buf += data
|
||||
self.parsePacket(conn)
|
||||
|
||||
@gen.coroutine
|
||||
def run(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user