public void Test() { var apc = Apc.Allocate(); apc.FunctionName = RpcMessageType.RequestCreateRoom; var msg = RequestCreateRoomMessage.Allocate(); msg.HallRoomId = 1; msg.MapId = 33; var player = RoomPlayer.Allocate(); player.Id = 4; msg.Players.Add(player); { MemoryStream stream = new MemoryStream(); if (msg != null) { _serializer.Serialize(stream, msg); } ByteString byteString = ByteString.CopyFrom(stream.ToArray()); apc.Parameters.Add(byteString); } NetworkChannelOnMessageReceived(null, 0, apc); msg.ReleaseReference(); }
public void Send(INetworkChannel channel, bool logmsg, string messageName, params IMessage[] messageBodys) { var apc = Apc.Allocate(); apc.FunctionName = messageName; foreach (var msg in messageBodys) { if (null == msg) { continue; } MemoryStream stream = new MemoryStream(); _serializer.Serialize(stream, msg); ByteString byteString = ByteString.CopyFrom(stream.ToArray()); apc.Parameters.Add(byteString); } channel.SendReliable(messageName.GetHashCode(), apc); if (logmsg) { _logger.InfoFormat("Send Rpc Message {0} hascode {1} ref count {2}", messageName, messageName.GetHashCode(), apc.RefCount); } apc.ReleaseReference(); }
public void Send(INetworkChannel channel, string messageName, params IMessage[] messageBodys) { var apc = Apc.Allocate(); apc.FunctionName = messageName; foreach (var msg in messageBodys) { if (null == msg) { continue; } MemoryStream stream = new MemoryStream(); _serializer.Serialize(stream, msg); ByteString byteString = ByteString.CopyFrom(stream.ToArray()); apc.Parameters.Add(byteString); } channel.SendReliable(messageName.GetHashCode(), apc); apc.ReleaseReference(); }