/// <summary> /// 发送SOCKET消息 /// </summary> public void SendMessage(int msgId, byte[] bytes) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteInt((ushort)bytes.Length + 4); buffer.WriteShort((ushort)msgId); buffer.WriteBytes(bytes); SocketClient.SendMessage(buffer); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 int protocal = dis == DisType.Exception ? Protocal.Exception : Protocal.Disconnect; ByteBuffer buffer = new ByteBuffer(); buffer.WriteShort((ushort)protocal); NetworkManager.AddEvent(protocal, buffer); Debug.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis); }