public void DispatchMessage(Session s, ByteStringArray bytes, ushort messageId) { if (this.OnGetServerMessage != null) { this.OnGetServerMessage(s, bytes, messageId); } }
public void Send(ByteStringArray data, ushort opcode) { if (this.IsDisposed) { throw new Exception("session已经被Dispose了"); } this.LastSendTime = TimeHelper.Now(); MemoryStream stream = this.Stream; stream.Seek(Packet.MessageIndex, SeekOrigin.Begin); stream.SetLength(Packet.MessageIndex); Array.Copy(data.data, 0, stream.GetBuffer(), Packet.MessageIndex, data.data.Length); stream.SetLength(Packet.MessageIndex + data.data.Length); stream.Seek(0, SeekOrigin.Begin); opcodeBytes.WriteTo(0, opcode); Array.Copy(opcodeBytes, 0, stream.GetBuffer(), 0, opcodeBytes.Length); this.Send(stream); }
public static String DecryptToString(ByteStringArray data, String key) { return(utf8.GetString(Decrypt(data.data, key))); }