partial void ImplSendMessage(NetMessage msg, ReliabilityMode reliable, BroadcastMode broadcast) { var lmsg = Manager.Room.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = reliable.PlayerDelivery(out seq); switch (broadcast) { case BroadcastMode.All: if (_observersAndOwner.Count > 0) { Manager.Room.PlayerServer.SendMessage(lmsg, _observersAndOwner, method, seq); } break; case BroadcastMode.Others: if (_observers.Count > 0) { Manager.Room.PlayerServer.SendMessage(lmsg, _observers, method, seq); } break; case BroadcastMode.Owner: Manager.Room.PlayerServer.SendMessage(lmsg, Owner.Connection, method, seq); break; default: throw new NotImplementedException(); } }
partial void ImplementationSendMessage(NetMessage msg, ReliabilityMode mode) { var lmsg = Room.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = mode.PlayerDelivery(out seq); Room.PlayerServer.SendMessage(lmsg, Connection, method, seq); }
partial void ImplSendToAllPlayersExcept(Player player, NetMessage msg, ReliabilityMode mode) { var lmsg = PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = mode.PlayerDelivery(out seq); PlayerServer.SendToAll(lmsg, player.Connection, method, seq); }
partial void ImplSend(NetMessage msg, ReliabilityMode mode, bool recycle) { var lmsg = Server.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); if (recycle) { NetMessage.RecycleMessage(msg); } int seq; var method = mode.PlayerDelivery(out seq); Server.PlayerServer.SendMessage(lmsg, Connection, method, seq); }
partial void ImplSendMessage(NetMessage msg, ReliabilityMode mode) { var lmsg = _room.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = mode.PlayerDelivery(out seq); if (seq == 2) { seq = 3; //don't use player channel... } _room.PlayerServer.SendToAll(lmsg, null, method, seq); }
partial void ImplSendExcept(NetMessage msg, Player player, ReliabilityMode mode) { var lmsg = Manager.Room.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = mode.PlayerDelivery(out seq); var conns = _observersAndOwner.Where(c => c != player.Connection).ToArray(); if (conns.Length == 0) { return; } Manager.Room.PlayerServer.SendMessage(lmsg, conns, method, seq); }
partial void ImplSendMessage(NetMessage msg, List <Player> players, ReliabilityMode mode) { var lmsg = Manager.Room.PlayerServer.CreateMessage(msg.Data.Length); msg.Clone(lmsg); NetMessage.RecycleMessage(msg); int seq; var method = mode.PlayerDelivery(out seq); var conns = new List <NetConnection>(players.Count); // ReSharper disable once LoopCanBeConvertedToQuery - speed foreach (var p in players) { conns.Add(p.Connection); } if (conns.Count == 0) { return; } Manager.Room.PlayerServer.SendMessage(lmsg, conns, method, seq); }