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