/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); NetworkManager.AddEvent(0, message); }
void OnReceivedMessage(byte[] message) { ByteBuffer buffer = new ByteBuffer(message); int mainId = buffer.ReadInt(); NetworkManager.AddEvent(mainId, buffer); }
private void OnReceivedMessage(MemoryStream ms) { BinaryReader binaryReader = new BinaryReader(ms); byte[] buf = binaryReader.ReadBytes((int)(ms.Length - ms.Position)); NetworkManager.AddEvent(104, new LuaByteBuffer(buf)); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 int protocal = dis == DisType.EXCEPTION ? Protocal.EXCEPTION : Protocal.DISCONNECT; NetworkManager.AddEvent(protocal, null); }
/// <summary> /// 连接上服务器 /// </summary> void OnConnect(IAsyncResult asr) { Debug.Log("连上了"); outStream = client.GetStream(); client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null); NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer()); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); ByteBuffer buffer = new ByteBuffer(message); NetworkManager.AddEvent(Protocal.Message, buffer); }
private void OnReceivedMessage(MemoryStream ms) { BinaryReader binaryReader = new BinaryReader(ms); byte[] data = binaryReader.ReadBytes((int)(ms.Length - ms.Position)); ByteBuffer data2 = new ByteBuffer(data); NetworkManager.AddEvent(104, data2); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="memoryStream"></param> private void OnReceivedMessage(MemoryStream memoryStream) { var binaryReader = new BinaryReader(memoryStream); var message = binaryReader.ReadBytes((int)(memoryStream.Length - memoryStream.Position)); var buffer = Encoding.UTF8.GetString(message); NetworkManager.AddEvent(Protocal.Message, buffer); }
static int AddEvent(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); int arg0 = (int)LuaScriptMgr.GetNumber(L, 1); ByteBuffer arg1 = LuaScriptMgr.GetNetObject <ByteBuffer>(L, 2); NetworkManager.AddEvent(arg0, arg1); return(0); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 int protocal = dis == DisType.Exception ? Protocal.Exception : Protocal.Disconnect; NetworkManager.AddEvent(protocal.ToString(), new LuaByteBuffer(new byte[] { })); Debug.LogWarning("Connection was closed by the server:>" + msg + " Distype:>" + dis); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { byte[] message = ms.ToArray(); //int msglen = message.Length; ByteBuffer buffer = new ByteBuffer(message); NetworkManager.AddEvent(Protocal.Message, buffer); ms.Close(); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(Protocal protocal, short error, string msg) { Close(); ByteBuffer buffer = new ByteBuffer(); buffer.WriteShort(error); buffer.WriteString(msg); NetworkManager.AddEvent((int)protocal, new ByteBuffer(buffer.ToBytes())); buffer.Close(); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(string msg) { Close(); //关掉客户端链接 if (OnEvent != null) { LuaByteBuffer buffer = new LuaByteBuffer(); NetworkManager.AddEvent(OnEvent, Protocal.Disconnect, ref buffer); } Debug.Log("Connection was closed by the server:>" + msg); }
/// <summary> /// 连接上服务器 /// </summary> void OnConnect(IAsyncResult asr) { try{ outStream = client.GetStream(); client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null); NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer()); } catch (Exception e) { Close(); Debug.LogError(e.Message); } }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 int protocol = dis == DisType.Exception ? Protocol.Exception : Protocol.Disconnect; ByteBuffer buffer = new ByteBuffer(); buffer.WriteShort((short)protocol); NetworkManager.AddEvent(protocol, buffer); }
/// <summary> /// 丢失链接 /// </summary> void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 string protocal = dis == DisType.Exception ? "Exception" : "Disconnect"; //ByteBuffer buffer = new ByteBuffer(); //buffer.WriteShort((ushort)protocal); NetworkManager.AddEvent(protocal); Debug.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis); }
private 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); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); ByteBuffer buffer = new ByteBuffer(message); int commandId = buffer.ReadShort(); NetworkManager.AddEvent(commandId, buffer); }
void AddEvent(int protocal, string message) { if (_networkManagerType == 1) { NetworkManager.AddEvent(protocal, message); } else if (_networkManagerType == 2) { NetworkManager2.AddEvent(protocal, message); } }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); //int msglen = message.Length; ByteBuffer buffer = new ByteBuffer(message); ushort mainId = buffer.ReadShort(); NetworkManager.AddEvent(mainId, buffer); }
/// <summary> /// 丢失链接 /// </summary> private void OnDisconnected(DisType dis, string msg) { Close(); //关掉客户端链接 var protocal = dis == DisType.Exception ? Protocal.Exception : Protocal.Disconnect; var buffer = new ByteBuffer(); buffer.WriteInt(protocal); NetworkManager.AddEvent(protocal, string.Empty); Util.LogError("Connection was closed by the server:>" + msg + " Distype:>" + dis); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); ByteBuffer buffer = new ByteBuffer(message); int mainId = buffer.ReadShort(); int pbDataLen = message.Length - 2; byte[] pbData = buffer.ReadBytes(pbDataLen); NetworkManager.AddEvent(mainId, pbData); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(int msgID, MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); LuaByteBuffer buffer = new LuaByteBuffer(message); if (OnMessage != null) { NetworkManager.AddEvent(OnMessage, msgID, ref buffer); } }
/// <summary> /// 连接上服务器 /// </summary> void OnConnect(IAsyncResult asr) { if (!client.Connected) { OnDisconnected(DisType.Exception, "can't connect to server."); return; } outStream = client.GetStream(); outStream.BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null); NetworkManager.AddEvent(Protocal.Connect, new ByteBuffer()); }
/// <summary> /// 连接上服务器 /// </summary> void ConnectCallback(IAsyncResult asr) { TcpClient socket = (TcpClient)asr.AsyncState; if (socket.Connected == false) { NetworkManager.AddEvent(Protocol.Refused, new ByteBuffer()); return; } outStream = client.GetStream(); client.GetStream().BeginRead(byteBuffer, 0, MAX_READ, new AsyncCallback(OnRead), null); NetworkManager.AddEvent(Protocol.Connect, new ByteBuffer()); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); //int msglen = message.Length; ByteBuffer buffer = new ByteBuffer(message); int rid = buffer.ReadInt(); Debug.Log("接收到的消息rid为------>" + rid); NetworkManager.AddEvent(rid, buffer); }
/// <summary> /// 接收到消息 /// </summary> /// <param name="ms"></param> void OnReceivedMessage(MemoryStream ms) { BinaryReader r = new BinaryReader(ms); byte[] message = r.ReadBytes((int)(ms.Length - ms.Position)); //int msglen = message.Length; ByteBuffer buffer = new ByteBuffer(message); // int mainId = buffer.ReadShort(); // Debug.Log(string.Format("OnReceivedMessage len {0}", message.Length)); NetworkManager.AddEvent(Protocal.Message, buffer); }
private void OnDisconnected(DisType dis, string msg) { this.Close(); int num = (dis != DisType.Exception) ? 103 : 102; ByteBuffer byteBuffer = new ByteBuffer(); byteBuffer.WriteShort((ushort)num); NetworkManager.AddEvent(num, byteBuffer); Debug.LogError(string.Concat(new object[] { "Connection was closed by the server:>", msg, 'Distype:>", dis }));
private void OnDisconnected(DisType dis, string msg) { this.Close(); int @event = (dis != DisType.Exception) ? 103 : 102; NetworkManager.AddEvent(@event, new LuaByteBuffer(Encoding.Default.GetBytes(msg))); Debug.LogWarning(string.Concat(new object[] { "Connection was closed by the server:>", msg, " Distype:>", dis })); }
private void OnConnect(IAsyncResult asr) { if (this.client.Connected) { this.outStream = this.client.GetStream(); this.client.GetStream().BeginRead(this.byteBuffer, 0, 8192, new AsyncCallback(this.OnRead), null); NetworkManager.AddEvent(101, new LuaByteBuffer(Encoding.Default.GetBytes("true"))); } else { NetworkManager.AddEvent(101, new LuaByteBuffer(Encoding.Default.GetBytes("false"))); } this.client.EndConnect(asr); }