/// <summary> /// 发送数据 /// </summary> /// <param name="data"></param> public void AsyncSendData(CWritePacket data) { if (m_Client == null || !m_Client.Connected) { return; } m_Client.BeginSend(data.GetPacketByte(), 0, data.GetPacketByte().Length, SocketFlags.None, new AsyncCallback(SendCallback), null); }
/// <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="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) { 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()); } }