/// <summary> /// 发送数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="id">玩家id</param> /// <param name="protocol">0</param> /// <param name="cmd">命令</param> /// <param name="t">协议</param> public void Send(UInt32 id, UInt32 protocol, Int32 cmd, byte[] datas) { if (state < 0) { Debug.Log("断线后,不发送数据"); } //else { Debug.Log("发送命令:" + cmd); } switch (type) { case NetWorkType.Kcp: kcp.Send(id, protocol, cmd, datas); break; case NetWorkType.Tcp: tcp.Send(id, protocol, cmd, datas); break; } }
void client_Event(UdpClientEvents arg1, byte[] arg2) { if (arg1 == UdpClientEvents.Recv) { RecvData(arg2); } else if (arg1 == UdpClientEvents.ConnectFail) { Console.WriteLine("连接失败"); } else if (arg1 == UdpClientEvents.ConnectTimeout) { Console.WriteLine("连接超时"); } else if (arg1 == UdpClientEvents.Connected) { client.Send("data:" + m_d.ToString()); } }
public void send(Message input) { kcp.Send <Message>(2, input); }