private unsafe void Send <R>(FramedClient client, long requestId, IReplyMessage <R> packet) { using (var ms = new MemoryStream()) { ms.SetLength(12); ms.Position = 12; serializer.Serialize(packet, ms); ms.Position = 0; var buffer = ms.GetBuffer(); fixed(byte *buf = buffer) { *(ActorProtocolFlags *)buf = ActorProtocolFlags.RequestReponse; *(long *)(buf + 4) = requestId; } client.SendPacket(new ArraySegment <byte>(buffer, 0, (int)ms.Length)); } }
private void AuxSendProtocolPacket <T>(int packetId, T packet) { using (var ms = new MemoryStream()) { ms.SetLength(8); ms.Position = 8; packetSerializer.Serialize(packet, ms); ms.Position = 0; var buffer = ms.GetBuffer(); unsafe { fixed(byte *b = buffer) { *(Proto.ActorProtocolFlags *)b = Proto.ActorProtocolFlags.StacksProtocol; *(int *)(b + 4) = packetId; } } framedClient.SendPacket(new ArraySegment <byte>(buffer, 0, (int)ms.Length)); } }