コード例 #1
0
ファイル: GameSender.cs プロジェクト: 56059943/test1
        //确认加密码改变
        public bool RetEncode(int serial, string info, int address)
        {
            StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_RET_ENCODE);//消息ID

            byte[] b = new byte[32];
            b = System.Text.Encoding.ASCII.GetBytes(info);

            ar.WriteUserDataNoLen(b);
            ar.WriteInt32(address);

            byte[] data  = new byte[256];
            int    index = 0;

            MsgEncode.WriteInt32(ref data, ref index, (uint)serial);
            MsgEncode.WriteInt32(ref data, ref index, (uint)address);

            //32位固定长度
            Array.Copy(b, 0, data, index, b.Length);
            index += b.Length;

            //校验码4个字节,对消息加密获取验证码
            byte[] varify = MsgEncode.Instance.Encode(data, index, 4);

            //byte[] varify = new byte[4];
            ar.WriteUserDataNoLen(varify);

            MsgEncode.Instance.Serial = (uint)serial;

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
コード例 #2
0
ファイル: GameSender.cs プロジェクト: 56059943/test1
        public bool ChooseRole(string role_name)
        {
            if (role_name == null)
            {
                //Log.TraceError("Role Name Is Empty!");
                return(false);
            }

            if (0 == role_name.Length)
            {
                //Log.Trace("sendChooseRole packet role name is empty!");
                return(false);
            }

            //byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1];
            //Array.Copy(System.Text.Encoding.Default.GetBytes(role_name), name, role_name.Length);

            StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_CHOOSE_ROLE);//消息ID

            //unsigned short wsName[OUTER_OBJNAME_LENGTH + 1];	// 名称
            //unsigned char nVerify[4];							// 校验码
            //char strInfo[1];

            ar.WriteUnicodeLen(role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);//玩家名

            //byte[] verify = new byte[4];
            //校验码4个字节,对消息加密获取验证码

            byte[] data  = new byte[256];
            int    index = 0;

            //序号,名字加入校验
            MsgEncode.WriteInt32(ref data, ref index, (uint)MsgEncode.Instance.Serial);
            MsgEncode.WriteUnicodeLen(ref data, ref index, role_name, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);

            byte[] verify = MsgEncode.Instance.Encode(data, index, 4);

            ar.WriteUserDataNoLen(verify); //检验码

            ar.WriteInt8(0);               //附加信息

            MsgEncode.Instance.MsgSerial++;

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
コード例 #3
0
ファイル: GameSender.cs プロジェクト: 56059943/test1
        public bool Select(string object_ident, int func_id)
        {
            if (object_ident == null)
            {
                //Log.TraceError("GameSender Select object_ident is null");
                return(false);
            }

            ObjectID objID = ObjectID.FromString(object_ident);

            StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_SELECT);//消息ID
            //unsigned char nVerify[4];	// 校验码
            //int nSerial;				// 消息序列号
            //outer_object_t ObjectId;	// 对象标识
            //int nFunctionId;			// 功能号为0表示执行缺省功能
            //byte[] message = TypeConvert.encode(m_buffer,ar.GetLength());

            byte[] data  = new byte[256];
            int    index = 0;

            //序号,名字加入校验
            MsgEncode.WriteInt16(ref data, ref index, (uint)MsgEncode.Instance.Serial);
            MsgEncode.WriteInt16(ref data, ref index, (uint)MsgEncode.Instance.MsgSerial);
            MsgEncode.WriteInt32(ref data, ref index, (uint)func_id);
            MsgEncode.WriteObject(ref data, ref index, objID);

            byte[] verify = MsgEncode.Instance.Encode(data, index, 4);

            ar.WriteUserDataNoLen(verify);               //检验码
            ar.WriteInt32(MsgEncode.Instance.MsgSerial); //消息序列号
            ar.WriteObject(objID);                       //对象标识
            ar.WriteInt32(func_id);
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }