public void SendPacket(CWritePacket packet) { if (packet != null) { SendData(packet.GetPacketByte(), packet.GetPacketLen(), packet.GetPacketID()); } }
//public WalkSend GetWalkSend () { return m_WalkSend; } //测试 public void SendPacket(CWritePacket packet) { if (packet != null) { //Debug.Log("messageid"+packet.GetPacketID()); SendData(packet.GetPacketByte(), packet.GetPacketLen(), packet.GetPacketID()); } }
/// <summary> /// 发送数据 /// </summary> /// <param name="data"></param> public void AsyncSendData(CWritePacket data) { if (m_Client == null || !m_Client.Connected || data == null) { return; } try { m_Client.GetStream().BeginWrite(data.GetPacketByte(), 0, data.GetPacketByte().Length, new AsyncCallback(OnWrite), null); } catch (Exception ex) { string parameter = string.Format("[m_nPacketID:{0}]", data.GetPacketID()); GameData.m_GameManager.LogMsgError("AsyncTcpClient", "AsyncSendData", parameter, ex.Message); } }
/// <summary> /// 发送数据 /// </summary> /// <param name="data"></param> public void AsyncSendData(CWritePacket data) { if (m_Client == null) { return; } try { m_Client.BeginSend(data.GetPacketByte(), data.GetPacketByte().Length, new AsyncCallback(SendCallback), null); } catch (Exception ex) { string parameter = string.Format("[m_nPacketID:{0}]", data.GetPacketID()); GameData.m_GameManager.LogMsgError("AsyncUdpClient", "AsyncSendData", parameter, ex.Message); } }
public void SendPacket(CWritePacket packet, C2SMessageType type = C2SMessageType.PASVWait) { //if (packet.GetPacketID() != MessageID.player_walk && packet.GetPacketID() != MessageID.s_player_attack_req // && packet.GetPacketID() != MessageID.pve_dungeon_list_req && packet.GetPacketID() != MessageID.s_player_revive_req // && packet.GetPacketID() != MessageID.s_player_change_scene) //{ // Globe.lastNetTime = 0; // Debug.Log(Globe.lastNetTime); // lastmessageid = packet.GetPacketID(); //} if (Singleton <SceneManage> .Instance.Current == EnumSceneID.UI_MajorCity01 || Globe.isFightGuide) { if (SceneManager.GetActiveScene().name == GameLibrary.UI_Major || Globe.isFightGuide) { switch (type) { case C2SMessageType.Active: break; case C2SMessageType.ActiveWait: GameLibrary.isSendPackage = true; if (Control.GetUIObject(UIPanleID.UIWaitForSever) != null) { Control.ShowGUI(UIPanleID.UIWaitForSever, EnumOpenUIType.DefaultUIOrSecond); } break; case C2SMessageType.PASVWait: // Debug.Log("True服务器正在接收其他消息 " + GameLibrary.isSendPackage); if (GameLibrary.isSendPackage) { return; } GameLibrary.isSendPackage = true; if (Control.GetUIObject(UIPanleID.UIWaitForSever) != null) { Control.ShowGUI(UIPanleID.UIWaitForSever, EnumOpenUIType.DefaultUIOrSecond); } break; } } } // Debug.Log("True代表服务器正在接收本次消息 " + GameLibrary.isSendPackage); if (ClientNetMgr.GetSingle().IsConnect()) { if (m_Parent != null) { m_Parent.SendPacket(packet); if (DataDefine.isLogMsg && DataDefine.filterWalkMsg(packet.GetPacketID())) { Debug.Log("Send msgid:" + packet.GetPacketID() + packet.GetLogPacketID() + " Sender: " + GetType() + " Time:" + Time.realtimeSinceStartup); } } } else { Debug.Log("和服务器已经断开了连接悄悄申请重连"); //if (UIPromptBox.Instance != null) //{ // UIPromptBox.Instance.ShowLabel("与服务器链接丢失,将重新与服务器建立链接"); //} Control.ShowGUI(UIPanleID.UIPromptBox, EnumOpenUIType.DefaultUIOrSecond, false, "与服务器链接丢失,将重新与服务器建立链接"); } }