コード例 #1
0
ファイル: protocol.py プロジェクト: zhsfei/taomee
	def make_vow(self, recv_id, item_id, item_name, num_bean):
		primsg=struct.pack(">LL30sL",recv_id, item_id, item_name, num_bean)
		sendbuf=self.pack(751, self.userid, primsg)
		self.get_socket().send(sendbuf)
		print "making vow....."
		print mypub.print_hex_16(sendbuf)
		pass
コード例 #2
0
    def dealmsg(self, cmdid, userid, result, primsg):
        if session_ser_proto.cmd_map.has_key(cmdid):
            #得到类名
            classname = session_ser_proto.cmd_map[cmdid][3]

            if classname <> None:
                pri_out = classname()
            else:
                pri_out = proto_base.Cmessage()

            ba = proto_base.Cbyte_array()
            ba.init_read_mode(primsg)
            if (result == 0):
                ret = pri_out.read_from_buf(ba)
                if (not ret):
                    print "解析出错:报文不够", classname
                if (ba.get_left_len() > 0):
                    print "解析出错:有剩余报文"
                    mypub.print_hex_16(primsg[ba.get_postion():])

            try:
                #得到调用函数
                cmd_name = session_ser_proto.cmd_map[cmdid][1]
                func_name = 'do_%s' % (cmd_name)
                print func_name
                func = getattr(self, func_name)
                func(result, primsg)
            except AttributeError:
                print "deal: userid=%d, %s[%d] : " % (userid, cmd_name, cmdid)
                pri_out.echo(True, "    ")
                pass
        else:
            print "未处理:", cmdid, result
            mypub.print_hex_16(primsg)
コード例 #3
0
ファイル: protocol.py プロジェクト: Zhanyin/taomee
 def check_vow(self):
     primsg = ""
     sendbuf = self.pack(754, self.userid, primsg)
     self.get_socket().send(sendbuf)
     print "check vow........"
     print mypub.print_hex_16(sendbuf)
     pass
コード例 #4
0
ファイル: protocol.py プロジェクト: Zhanyin/taomee
 def make_vow(self, recv_id, item_id, item_name, num_bean):
     primsg = struct.pack(">LL30sL", recv_id, item_id, item_name, num_bean)
     sendbuf = self.pack(751, self.userid, primsg)
     self.get_socket().send(sendbuf)
     print "making vow....."
     print mypub.print_hex_16(sendbuf)
     pass
コード例 #5
0
ファイル: protocol.py プロジェクト: Zhanyin/taomee
 def check_bag(self, itemid):
     primsg = struct.pack(">L", itemid)
     sendbuf = self.pack(513, self.userid, primsg)
     self.get_socket().send(sendbuf)
     print "check bag........."
     print mypub.print_hex_16(sendbuf)
     pass
コード例 #6
0
ファイル: protocol.py プロジェクト: Zhanyin/taomee
 def sell_goods(self, itemid, price, count, session):
     primsg = struct.pack(">LLL8s", itemid, price, count, session)
     sendbuf = self.pack(514, self.userid, primsg)
     self.get_socket().send(sendbuf)
     print "selling goods........"
     print mypub.print_hex_16(sendbuf)
     pass
コード例 #7
0
 def sendmsg(self, cmdid, pri_in):
     sendbuf = self.pack(cmdid, pri_in)
     mypub.print_hex_16(sendbuf)
     if (self.is_tcp()):
         self.getsock().send(sendbuf)
     else:
         self.getsock().sendto(sendbuf, (self.ip, self.port))
コード例 #8
0
    def dealmsg(self, proto_model, cmdid, result, primsg):
        if proto_model.cmd_map.has_key(cmdid):
            #得到类名
            classname = proto_model.cmd_map[cmdid][3]

            if classname <> None:
                pri_out = classname()
            else:
                pri_out = Cmessage()

            ba = Cbyte_array()
            ba.init_read_mode(primsg)
            ba.set_is_big_endian(self.m_is_big_endian)
            ret = pri_out.read_from_buf(ba)
            if (not ret):
                print "解析出错:报文不够"
            if (ba.get_left_len() > 0):
                print "解析出错:有剩余报文"
                mypub.print_hex_16(primsg[ba.get_postion():])

            try:
                #得到调用函数
                cmd_name = proto_model.cmd_map[cmdid][1]
                func_name = 'do_%s' % (cmd_name)
                print func_name
                func = getattr(self, func_name)
                func(result, primsg)
            except AttributeError:
                print "deal:  %s[%d] : " % (cmd_name, cmdid)
                pri_out.echo(False, "    ")
                pass
        else:
            print "未处理:", cmdid, result
            mypub.print_hex_16(primsg)
コード例 #9
0
ファイル: protoCore.py プロジェクト: zhsfei/taomee
 def check_bag(self, itemid):
     primsg = struct.pack(">L", itemid)
     sendbuf = self.pack(513, self.userid, primsg)
     self.getsock().send(sendbuf)
     print "check_bag"
     mypub.print_hex_16(sendbuf)
     pass
コード例 #10
0
ファイル: protoCore.py プロジェクト: Zhanyin/taomee
 def check_bag(self,itemid):
     primsg=struct.pack(">L",itemid);
     sendbuf=self.pack(513,self.userid,primsg);
     self.getsock().send(sendbuf)
     print "check_bag"
     mypub.print_hex_16(sendbuf);
     pass
コード例 #11
0
ファイル: protocol.py プロジェクト: zhsfei/taomee
	def sell_goods(self,itemid,price, count, session):
		primsg=struct.pack(">LLL8s",itemid,price,count,session);
		sendbuf=self.pack(514,self.userid,primsg); 
		self.get_socket().send(sendbuf) 
		print "selling goods........"
		print mypub.print_hex_16(sendbuf);
		pass
コード例 #12
0
ファイル: protocol.py プロジェクト: zhsfei/taomee
	def check_vow(self):
		primsg=""
		sendbuf=self.pack(754,self.userid,primsg) 
		self.get_socket().send(sendbuf) 
		print "check vow........"
		print mypub.print_hex_16(sendbuf);
		pass
コード例 #13
0
ファイル: protocol.py プロジェクト: zhsfei/taomee
	def check_bag(self, itemid):
		primsg=struct.pack(">L",itemid);
		sendbuf=self.pack(513,self.userid,primsg); 
		self.get_socket().send(sendbuf) 
		print "check bag........."
		print mypub.print_hex_16(sendbuf);
		pass
コード例 #14
0
ファイル: proto_base.py プロジェクト: Zhanyin/taomee
    def dealmsg(self,proto_model,cmdid,result,primsg):
        if proto_model.cmd_map.has_key(cmdid):
            #得到类名
            classname=proto_model.cmd_map[cmdid][3];

            if classname <> None:	
                pri_out=classname() ;
            else:
                pri_out=Cmessage();

            ba=Cbyte_array();
            ba.init_read_mode(primsg);
            ba.set_is_big_endian(self.m_is_big_endian);
            ret=pri_out.read_from_buf(ba);
            if ( not  ret ):
                print "解析出错:报文不够";
            if (ba.get_left_len() >0 ):
                print "解析出错:有剩余报文";
                mypub.print_hex_16(primsg[ba.get_postion():] );

            try:
                #得到调用函数
                cmd_name=proto_model.cmd_map[cmdid][1];
                func_name='do_%s'%( cmd_name ) 
                print func_name
                func = getattr( self , func_name )
                func(result,primsg);
            except AttributeError:
                print "deal:  %s[%d] : "%(cmd_name , cmdid )
                pri_out.echo(False, "    ");
                pass
        else:
            print "未处理:", cmdid, result
            mypub.print_hex_16(primsg)
コード例 #15
0
ファイル: proto_base.py プロジェクト: Zhanyin/taomee
 def sendmsg(self, cmdid,pri_in ):
     sendbuf=self.pack(cmdid,pri_in);
     mypub.print_hex_16(sendbuf );
     if (self.is_tcp()):
         self.getsock().send(sendbuf)
     else:
         self.getsock().sendto(sendbuf,(self.ip,self.port) )
コード例 #16
0
ファイル: protocol.py プロジェクト: Zhanyin/taomee
    def cd_map(self, mapid):
        primsg = ""
        sendbuf = self.pack(402, self.userid, primsg)
        print mypub.print_hex_16(sendbuf)
        self.get_socket().send(sendbuf)

        primsg = struct.pack(">LL", mapid, 0)
        sendbuf = self.pack(401, self.userid, primsg)
        print mypub.print_hex_16(sendbuf)
        self.get_socket().send(sendbuf)
        pass
コード例 #17
0
ファイル: protocol.py プロジェクト: zhsfei/taomee
	def cd_map(self,mapid):
		primsg="";
		sendbuf=self.pack(402,self.userid,primsg); 
		print mypub.print_hex_16(sendbuf);
		self.get_socket().send(sendbuf) 

		primsg=struct.pack(">LL",mapid,0);
		sendbuf=self.pack(401,self.userid,primsg); 
		print mypub.print_hex_16(sendbuf);
		self.get_socket().send(sendbuf) 
		pass
コード例 #18
0
	def dealmsg(self,cmdid,userid,result,primsg):
		if mole2_online_proto.cmd_map.has_key(cmdid):
			#得到类名
			classname=mole2_online_proto.cmd_map[cmdid][3];

			if classname <> None:	
				pri_out=classname() ;
			else:
				pri_out=proto_base.Cmessage();
			
			ba=proto_base.Cbyte_array();
			ba.set_is_big_endian(True);
			ba.init_read_mode(primsg);
			if (result==0 ):
				ret=pri_out.read_from_buf(ba);
				if ( not  ret ):
					print "解析出错:报文不够",classname;
				if (ba.get_left_len() >0 ):
					print "解析出错:有剩余报文";
					mypub.print_hex_16(primsg[ba.get_postion():] );
			

			try:
				#得到调用函数
 				cmd_name=mole2_online_proto.cmd_map[cmdid][1];
				func_name='do_%s'%( cmd_name ) 
				print func_name
				func = getattr(self , func_name  )
				func(result,primsg);
			except AttributeError:
				print "deal: userid=%d, %s[%d] : "%(userid,cmd_name , cmdid )
				pri_out.echo(True, "    ");
				pass
		else:
			print "未处理:", cmdid, result
			mypub.print_hex_16(primsg)
コード例 #19
0
ファイル: send_package.py プロジェクト: zhsfei/taomee
def capture_message(protocol_instance, *args):
    while 1:
        out_info = protocol_instance.getrecvmsg()
        if (out_info):
            proto_len, version, cmdid, userid, result, pri_msg = out_info
            print cmdid, result, userid, mypub.print_hex_16(pri_msg, 0)