public void IOSGameGameCenterVerifySuccess(string result) { PrintLog("gamecenterlogincallback:" + result); Dictionary <string, object> dict = (Dictionary <string, object>)Jsontext.ReadeData(result); //string url = HttpUtility.UrlEncode("publicKeyUrl"); //PrintLog($"encode后的url {url}"); //System.Text.StringBuilder stringbuilder = Jsontext.WriteData(dict); //stringbuilder.Append("\0"); //PrintLog($"要发送的json {stringbuilder.ToString()}"); string sigEncode = HttpUtility.UrlEncode((string)dict["signature"]); dict["signature"] = sigEncode; System.Text.StringBuilder sb = Jsontext.WriteData(dict); sb.Append("\0"); // TODO 向游戏服务器发送请求登录消息 [2020/1/18 14:40:41 BingLau] StartCoroutine(LoginGame(sb.ToString())); }
/// <summary> /// 发送ping包 /// </summary> /// <param name="data"></param> public void AsyncSendPing() { IDictionary <string, object> packet = new Dictionary <string, object>(); packet.Add("msgid", NetProtocol.PING); CWritePacket writePacket = new CWritePacket(NetProtocol.PING); StringBuilder builder = Jsontext.WriteData(packet); string json_Str = builder.ToString(); writePacket.WriteString(json_Str); m_Client.BeginSend(writePacket.GetPacketByte(), writePacket.GetPacketByte().Length, new AsyncCallback(SendCallback), null); }
/// <summary> /// 登录游戏 /// </summary> /// <param name="cmd"></param> /// <param name="parameter"></param> public CWritePacket InputLogin(string account) { IDictionary <string, object> packet = new Dictionary <string, object>(); packet.Add("msgid", NetProtocol.LOGIN_REQ); packet.Add("account", account); CWritePacket writePacket = new CWritePacket(NetProtocol.LOGIN_REQ); StringBuilder builder = Jsontext.WriteData(packet); string json_Str = builder.ToString(); writePacket.WriteString(json_Str); return(writePacket); }
/// <summary> /// 参加匹配 /// </summary> /// <param name="cmd"></param> /// <param name="parameter"></param> public CWritePacket InputMatch(int matchType) { IDictionary <string, object> packet = new Dictionary <string, object>(); packet.Add("msgid", NetProtocol.MATCH_REQ); packet.Add("playerId", GameData.m_CurrentRoleId); packet.Add("matchType", matchType); CWritePacket writePacket = new CWritePacket(NetProtocol.MATCH_REQ); StringBuilder builder = Jsontext.WriteData(packet); string json_Str = builder.ToString(); writePacket.WriteString(json_Str); return(writePacket); }
/// <summary> /// 准备操作 /// </summary> /// <param name="cmd"></param> /// <param name="parameter"></param> public CWritePacket InputReady() { IDictionary <string, object> packet = new Dictionary <string, object>(); packet.Add("msgid", NetProtocol.READY); packet.Add("playerId", GameData.m_CurrentRoleId); packet.Add("heroId", GameData.m_HeroId); packet.Add("mobaKey", GameData.m_MobaKey); CWritePacket writePacket = new CWritePacket(NetProtocol.READY); StringBuilder builder = Jsontext.WriteData(packet); string json_Str = builder.ToString(); writePacket.WriteString(json_Str); return(writePacket); }
void Send(Dictionary <string, object> newpacket, CWritePacket packet) { System.Text.StringBuilder stringbuilder = Jsontext.WriteData(newpacket); stringbuilder.Append("\0"); string json_s = stringbuilder.ToString(); if (DataDefine.isEFS == 1) { //加密处理 json_s = packet.Compress(json_s, DataDefine.datakey); } packet.WriteString(json_s); // Debug.Log( json_s ); SendPacket(packet, C2SMessageType.Active); }
protected void PacketDictAndSend(UInt32 msgID, Dictionary <string, object> newpacket, C2SMessageType c2sType = C2SMessageType.PASVWait) { CWritePacket packet = new CWritePacket(msgID); System.Text.StringBuilder stringbuilder = Jsontext.WriteData(newpacket); stringbuilder.Append("\0"); string json_s = stringbuilder.ToString(); if (DataDefine.isEFS == 1) { //加密处理 json_s = packet.Compress(json_s, DataDefine.datakey); } packet.WriteString(json_s); if (DataDefine.isLogMsgDetail) { Debug.Log("Send msgDetail: " + json_s); } SendPacket(packet, c2sType); }
/// <summary> /// 输入操作 /// </summary> /// <param name="cmd"></param> /// <param name="parameter"></param> public CWritePacket InputCmd(Cmd cmd, string parameter = null) { FrameKeyData frameKeyData = new FrameKeyData(); frameKeyData.m_KeyDataList = new List <KeyData>(); KeyData data = new KeyData(); data.m_RoleId = GameData.m_CurrentRoleId; data.m_Cmd = (int)cmd; data.m_Parameter = parameter; frameKeyData.m_KeyDataList.Add(data); Dictionary <string, object> packet = new Dictionary <string, object>(); packet.Add("msgid", NetProtocol.SYNC_KEY); packet.Add("roleid", GameData.m_CurrentRoleId); packet.Add("mobaKey", GameData.m_MobaKey); packet.Add("keydatalist", frameKeyData.m_KeyDataList); CWritePacket writePacket = new CWritePacket(NetProtocol.SYNC_KEY); StringBuilder builder = Jsontext.WriteData(packet); string json_Str = builder.ToString(); writePacket.WriteString(json_Str); return(writePacket); }