private void SendGamerLeft(LocalNetworkGamer localGamer) { var msg = CreateMessageWithHeader(MessageType.GamerLeft, null); msg.Write(localGamer.id); SendMessage(msg, NetDeliveryMethod.ReliableOrdered); }
public OutboundPacket(Packet packet, LocalNetworkGamer sender, NetworkGamer recipient, SendDataOptions options) { this.packet = packet; this.sender = sender; this.recipient = recipient; this.options = options; }
internal void SendGamerStateChanged(LocalNetworkGamer localGamer) { var msg = CreateMessageWithHeader(MessageType.GamerStateChanged, null); msg.Write(localGamer.id); msg.Write(localGamer.DisplayName); msg.Write(localGamer.Gamertag); msg.Write(localGamer.isReady); SendMessage(msg, NetDeliveryMethod.ReliableOrdered); }
internal void SendUserMessage(LocalNetworkGamer sender, SendDataOptions options, byte[] data, NetworkGamer recipient = null) { var msg = CreateMessageWithHeader(MessageType.User, recipient != null ? recipient.machine : null); msg.Write(sender.id); msg.Write((byte)(recipient == null ? 255 : recipient.id)); msg.Write((byte)options); msg.Write(data.Length); msg.Write(data); SendMessage(msg, ToDeliveryMethod(options)); }
private void SendGamerJoined(LocalNetworkGamer localGamer, NetworkMachine recipient) { var msg = CreateMessageWithHeader(MessageType.GamerJoined, recipient); msg.Write(localGamer.id); msg.Write(localGamer.DisplayName); msg.Write(localGamer.Gamertag); msg.Write(localGamer.isPrivateSlot); msg.Write(localGamer.isReady); SendMessage(msg, NetDeliveryMethod.ReliableOrdered); }
private bool ReceiveGamerIdResponse(NetBuffer msg, NetworkMachine originMachine) { if (!originMachine.isHost) { return(false); } bool slotAvailable; byte id; try { slotAvailable = msg.ReadBoolean(); id = msg.ReadByte(); } catch { return(false); } if (slotAvailable && id == 255) { return(false); } if (pendingSignedInGamers.Count == 0) { // Don't treat as error but host will have marked slot used by client return(true); } if (!slotAvailable) { pendingSignedInGamers.RemoveAt(0); return(true); } var signedInGamer = pendingSignedInGamers[0]; pendingSignedInGamers.RemoveAt(0); var isPrivateSlot = isHost && GetOpenPrivateGamerSlots() > 0; var localGamer = new LocalNetworkGamer(signedInGamer, localMachine, id, isPrivateSlot); AddGamer(localGamer); SendGamerJoined(localGamer, null); return(true); }
internal void SendUserMessage(LocalNetworkGamer sender, SendDataOptions options, PacketWriter data, NetworkGamer recipient = null) { var msg = CreateMessageWithHeader(MessageType.User, recipient != null ? recipient.machine : null); msg.Write(sender.id); msg.Write((byte)(recipient == null ? 255 : recipient.id)); msg.Write((byte)options); msg.Write(data.Length); data.BaseStream.Position = 0; int dataByte; while ((dataByte = data.BaseStream.ReadByte()) != -1) { msg.Write((byte)dataByte); } SendMessage(msg, ToDeliveryMethod(options)); }