public static AddEvent ( string _event, NetBuffer, data ) : void | ||
_event | string | |
data | NetBuffer, | |
Résultat | void |
void Disconnected(DisconnectType dis, string msg) { Close(); string protocal = dis == DisconnectType.System ? SocketStatusCMD.Exception : SocketStatusCMD.Disconnect; NetByteBuffer buffer = new NetByteBuffer(); buffer.WriteString(protocal); SocketClientManager.AddEvent(protocal, buffer); DebugConsole.LogError("Disconnected :>" + msg + " DisconnectType:>" + dis); }
void OnReceivedInternal(MemoryStream ms) { BinaryReader br = new BinaryReader(ms); byte[] message = br.ReadBytes((int)(ms.Length - ms.Position)); br.Close(); ms.Close(); ms.Dispose(); NetByteBuffer temp = new NetByteBuffer(message); ushort cmd = temp.ReadShort(); byte[] buf = temp.ReadRemaining(); SocketClientManager.AddEvent(cmd.ToString(), new NetByteBuffer(buf)); }
void OnConnect(IAsyncResult asr) { sendStream = client.GetStream(); client.GetStream().BeginRead(receiveBuffer, 0, MAX_READ_LENGTH, new AsyncCallback(OnRead), null); SocketClientManager.AddEvent(SocketStatusCMD.Connect, new NetByteBuffer()); }