Пример #1
0
 public void SendData(
     PacketWriter data,
     SendDataOptions options)
 {
     SendData(data.Data, 0, data.Length, options, null);
     data.Reset();
 }
Пример #2
0
 internal void SendData(
     byte[] data,
     SendDataOptions options,
     NetworkGamer gamer)
 {
     this.SendMessage(NetworkMessageType.Data, data, options, gamer);
 }
Пример #3
0
 public void newJuggernaut(NetworkGamer gamer) //Announces who shall be the new juggernaut.
 {
     dataOptions = SendDataOptions.ReliableInOrder;
     writer.Write((byte)MessageType.NewJuggernaut);
     writer.Write(gamer.Gamertag);
     Global.msgNewJuggernaut(gamer.Gamertag); //Fires off a message to the message displayer unit.
 }
Пример #4
0
 public void SendData(
     byte[] data,
     SendDataOptions options
     )
 {
     throw new NotImplementedException();
 }
Пример #5
0
 public void SendData(
     PacketWriter data,
     SendDataOptions options
     )
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public OutboundPacket(Packet packet, LocalNetworkGamer sender, NetworkGamer recipient, SendDataOptions options)
 {
     this.packet    = packet;
     this.sender    = sender;
     this.recipient = recipient;
     this.options   = options;
 }
Пример #7
0
		public void SendData (
			byte[] data,
			SendDataOptions options)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, 0, data.Length, options, null, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #8
0
 public void SendData(
     PacketWriter data,
     SendDataOptions options,
     NetworkGamer recipient)
 {
     SendData(data.Data, 0, data.Length, options, recipient);
     data.Reset();
 }
Пример #9
0
		public void SendData (
			byte[] data,
			SendDataOptions options,
			NetworkGamer recipient)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, 0, data.Length, options, recipient, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #10
0
        internal void SendData(
            byte[] data,
            SendDataOptions options)
        {
#if !PORTABLE
            this.SendMessage(NetworkMessageType.Data, data, options, null);
#endif
        }
Пример #11
0
        private void SendMessage(NetworkMessageType messageType, byte[] data, SendDataOptions options, NetworkGamer gamer)
        {
            NetOutgoingMessage message = ((NetPeer)this.peer).CreateMessage();

            message.Write((byte)messageType);
            message.Write(data);
            this.SendMessage(message, options, gamer);
        }
Пример #12
0
 public void SendData(
     byte[] data,
     SendDataOptions options,
     NetworkGamer recipient
     )
 {
     SendData(data, 0, data.Length, options, recipient);
 }
Пример #13
0
 public void SendData(
     PacketWriter data,
     SendDataOptions options,
     NetworkGamer recipient
     )
 {
     throw new NotImplementedException();
 }
Пример #14
0
 public void SendData(
     byte[] data,
     SendDataOptions options,
     NetworkGamer recipient
     )
 {
     throw new NotImplementedException();
 }
Пример #15
0
		public void SendData (
			byte[] data,
			int offset,
			int count,
			SendDataOptions options)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, offset, count, options, null, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #16
0
 public void SendData(
     byte[] data,
     int offset,
     int count,
     SendDataOptions options
     )
 {
     throw new NotImplementedException();
 }
Пример #17
0
        private void SendMessage(NetworkMessageType messageType, byte[] data, SendDataOptions options, NetworkGamer gamer)
        {
            NetOutgoingMessage om = peer.CreateMessage();

            om.Write((byte)messageType);
            om.Write(data);

            SendMessage(om, options, gamer);
        }
Пример #18
0
        public void SendData(PacketWriter data, SendDataOptions options, NetworkGamer recipient)
        {
            if (recipient == null)
            {
                throw new NullReferenceException("recipient");
            }

            try { InternalSendData(data, options, recipient); }
            catch { throw; }
        }
Пример #19
0
		public void SendData (
			byte[] data,
			int offset,
			int count,
			SendDataOptions options,
			NetworkGamer recipient)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, offset, count, options, recipient,this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #20
0
 public void playerUpdate(LocalPlayer player)
 {
     dataOptions = SendDataOptions.Reliable;
     writer.Write((byte)MessageType.PlayerUpdate);
     writer.Write(player.gamer.Gamertag);
     writer.Write(player.Position);
     writer.Write(player.Velocity);
     writer.Write(player.camera.pitch);
     writer.Write(player.camera.yaw);
 }
Пример #21
0
        public void SendData(byte[] data, int offset, int count, SendDataOptions options, NetworkGamer recipient)
        {
            if (recipient == null)
            {
                throw new NullReferenceException("recipient");
            }

            try { InternalSendData(data, offset, count, options, recipient); }
            catch { throw; }
        }
Пример #22
0
        public void SendData(byte[] data, SendDataOptions options, NetworkGamer recipient)
        {
            if (recipient == null)
            {
                throw new NullReferenceException("recipient");
            }

            try { InternalSendData(data, 0, data.Length, options, recipient); }
            catch { throw; }
        }
Пример #23
0
        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));
        }
Пример #24
0
 public CommandSendData(byte[] data, int offset, int count, SendDataOptions options, NetworkGamer gamer)
 {
     if (gamer != null)
         gamerInternalIndex = gamer.Id;
     this.data = new byte[count];
     Array.Copy(data, offset, this.data, 0, count);
     this.offset = offset;
     this.count = count;
     this.options = options;
     this.gamer = gamer;
 }
Пример #25
0
 public CommandSendData(byte[] data, int offset, int count, SendDataOptions options, NetworkGamer gamer, LocalNetworkGamer sender)
 {
     if (gamer != null)
     {
         this.gamerInternalIndex = (int)gamer.Id;
     }
     this.data = new byte[count];
     Array.Copy((Array)data, offset, (Array)this.data, 0, count);
     this.offset  = offset;
     this.count   = count;
     this.options = options;
     this.gamer   = gamer;
     this.sender  = sender;
 }
Пример #26
0
        private static bool IsSendDataOptionsValid(SendDataOptions options)
        {
            switch (options)
            {
            case SendDataOptions.InOrder:
            case SendDataOptions.Reliable:
            case SendDataOptions.ReliableInOrder:
            case SendDataOptions.Chat:
            case SendDataOptions.Chat | SendDataOptions.InOrder:
                return(true);

            default:
                return(false);
            }
        }
Пример #27
0
 public void fireBullet(Bullet bullet)
 {
     dataOptions = SendDataOptions.Reliable;
     writer.Write((byte)MessageType.FireBullet);
     writer.Write(bullet.startPosition);
     writer.Write(bullet.Velocity);
     if (bullet.shooter == null)
     {
         writer.Write("bot");
     }
     else
     {
         writer.Write(bullet.shooter.Gamertag);
     }
     writer.Write(bullet.damage);
 }
Пример #28
0
        private void InternalSendData(PacketWriter data, SendDataOptions options, NetworkGamer recipient)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (data.Length == 0)
            {
                throw new NetworkException("PacketWriter empty");
            }

            session.SendUserMessage(this, options, data, recipient);

            data.BaseStream.SetLength(0);
            data.BaseStream.Position = 0;
        }
Пример #29
0
        internal bool AddInboundPacket(Packet packet, byte senderId, SendDataOptions options)
        {
            var sender = session.FindGamerById(senderId);

            if (options == SendDataOptions.InOrder || options == SendDataOptions.ReliableInOrder)
            {
                bool packetsInQueue = delayedOrdered.ContainsKey(senderId) && delayedOrdered[senderId].Count > 0;

                if (sender == null || packetsInQueue)
                {
                    if (!delayedOrdered.ContainsKey(senderId))
                    {
                        delayedOrdered.Add(senderId, new List <Packet>());
                    }
                    if (delayedOrdered[senderId].Count > MaxDelayedPacketsAllowed)
                    {
                        return(false);
                    }
                    delayedOrdered[senderId].Add(packet);
                }
                else
                {
                    inboundPackets.Add(new InboundPacket(packet, sender));
                }
            }
            else
            {
                if (sender == null)
                {
                    if (!delayedUnordered.ContainsKey(senderId))
                    {
                        delayedUnordered.Add(senderId, new List <Packet>());
                    }
                    if (delayedUnordered.Count > MaxDelayedPacketsAllowed)
                    {
                        return(false);
                    }
                    delayedUnordered[senderId].Add(packet);
                }
                else
                {
                    inboundPackets.Add(new InboundPacket(packet, sender));
                }
            }

            return(true);
        }
Пример #30
0
 public void SendData(PacketWriter data, SendDataOptions options)
 {
     // FIXME: Do we want to alloc like this? -flibit
     byte[] mem = (data.BaseStream as System.IO.MemoryStream).ToArray();
     data.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
     foreach (NetworkGamer gamer in Session.AllGamers)
     {
         NetworkSession.NetworkEvent evt = new NetworkSession.NetworkEvent()
         {
             Type     = NetworkSession.NetworkEventType.PacketSend,
             Gamer    = gamer,
             Packet   = mem,
             Reliable = options
         };
         Session.SendNetworkEvent(evt);
     }
 }
Пример #31
0
 /// <summary>
 /// Sends data for the specified <see cref="LocalNetworkGamer"/> across the network.
 /// </summary>
 /// <param name="senderIndex">The index of the <see cref="LocalNetworkGamer"/> that is in Session.LocalGamers to send data for.</param>
 /// <param name="recipient">The recipient of the data, or null if to send to everyone.</param>
 /// <param name="options">The <see cref="SendDataOptions"/> to send the data with.</param>
 public virtual void SendData(int senderIndex, NetworkGamer recipient, SendDataOptions options)
 {
     if (!IsNetworking)
     {
         throw new InvalidOperationException("This component is not currently active.");
     }
     if (senderIndex >= Session.LocalGamers.Count || senderIndex < 0)
     {
         throw new ArgumentOutOfRangeException("senderIndex", "The senderIndex parameter is outside of the bounds of Session.LocalGamers.");
     }
     if (recipient != null)
     {
         Session.LocalGamers[senderIndex].SendData(_dataWriters[Session.LocalGamers[senderIndex].Id], options, recipient);
     }
     else
     {
         Session.LocalGamers[senderIndex].SendData(_dataWriters[Session.LocalGamers[senderIndex].Id], options);
     }
 }
Пример #32
0
		public void SendData (
         PacketWriter data,
         SendDataOptions options
)
		{
			throw new NotImplementedException();
		}
Пример #33
0
		public void SendData (
			PacketWriter data,
			SendDataOptions options,
			NetworkGamer recipient)
		{
			SendData(data.Data, 0, data.Length, options, recipient);
			data.Reset();
		}
Пример #34
0
		public void SendData (
			PacketWriter data,
			SendDataOptions options)
		{
			SendData(data.Data, 0, data.Length, options, null);
			data.Reset();
		}
Пример #35
0
		public void SendData (
			byte[] data,
			SendDataOptions options,
			NetworkGamer recipient)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, 0, data.Length, options, recipient, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #36
0
		public void SendData (
			byte[] data,
			SendDataOptions options)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, 0, data.Length, options, null, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #37
0
		public void SendData (
			byte[] data,
			int offset,
			int count,
			SendDataOptions options,
			NetworkGamer recipient)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, offset, count, options, recipient,this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #38
0
		public void SendData (
			byte[] data,
			int offset,
			int count,
			SendDataOptions options)
		{
			CommandEvent cme = new CommandEvent(new CommandSendData(data, offset, count, options, null, this ));
			Session.commandQueue.Enqueue(cme);
		}
Пример #39
0
		internal void SendData (
			byte[] data,
			SendDataOptions options)
		{
			this.SendMessage (NetworkMessageType.Data, data, options, null);
		}
Пример #40
0
 public void SendData(PacketWriter data, SendDataOptions options)
 {
   this.SendData(data.Data, 0, data.Length, options, (NetworkGamer) null);
   data.Reset();
 }
Пример #41
0
 private void SendMessage(NetOutgoingMessage om, SendDataOptions options, NetworkGamer gamer)
 {
   NetDeliveryMethod netDeliveryMethod = (NetDeliveryMethod) 1;
   switch (options)
   {
     case SendDataOptions.None:
       netDeliveryMethod = (NetDeliveryMethod) 0;
       break;
     case SendDataOptions.Reliable:
       netDeliveryMethod = (NetDeliveryMethod) 35;
       break;
     case SendDataOptions.InOrder:
       netDeliveryMethod = (NetDeliveryMethod) 2;
       break;
     case SendDataOptions.ReliableInOrder:
       netDeliveryMethod = (NetDeliveryMethod) 67;
       break;
   }
   this.peer.SendToAll(om, netDeliveryMethod);
 }
Пример #42
0
		public void SendData (
         byte[] data,
         SendDataOptions options,
         NetworkGamer recipient
)
		{
			throw new NotImplementedException();
		}
Пример #43
0
		public void SendData (
         byte[] data,
         SendDataOptions options
)
		{
			throw new NotImplementedException();
		}
Пример #44
0
 public void SendToAll(NetworkSession networkSession, Microsoft.Xna.Framework.Net.PacketWriter writer, SendDataOptions option)
 {
     foreach (NetworkGamer gamer in networkSession.RemoteGamers)
     {
         networkSession.LocalGamers[0].SendData(writer, option, gamer);
     }
 }
Пример #45
0
 private void SendMessage(NetworkMessageType messageType, byte[] data, SendDataOptions options, NetworkGamer gamer)
 {
   NetOutgoingMessage message = ((NetPeer) this.peer).CreateMessage();
   message.Write((byte) messageType);
   message.Write(data);
   this.SendMessage(message, options, gamer);
 }
Пример #46
0
		public void SendData (
         PacketWriter data,
         SendDataOptions options,
         NetworkGamer recipient
)
		{
			throw new NotImplementedException();
		}
Пример #47
0
		public void SendData (
         byte[] data,
         int offset,
         int count,
         SendDataOptions options
)
		{
			throw new NotImplementedException();
		}
Пример #48
0
		private void SendMessage (NetworkMessageType messageType, byte[] data, SendDataOptions options, NetworkGamer gamer)
		{

			NetOutgoingMessage om = peer.CreateMessage ();

			om.Write ((byte)messageType);
			om.Write (data);

			SendMessage (om, options, gamer);

		}
Пример #49
0
		internal void SendData (
			byte[] data,
			SendDataOptions options,
			NetworkGamer gamer)
		{
			this.SendMessage (NetworkMessageType.Data, data, options, gamer);
		}
Пример #50
0
 public void SendData(byte[] data, int offset, int count, SendDataOptions options)
 {
   this.Session.commandQueue.Enqueue(new CommandEvent((ICommand) new CommandSendData(data, offset, count, options, (NetworkGamer) null, this)));
 }
Пример #51
0
		private void SendMessage (NetOutgoingMessage om, SendDataOptions options, NetworkGamer gamer)
		{
			//Console.WriteLine("Data to send: " + data.Length);

			//			foreach (NetConnection player in server.Connections) {
			//				// ... send information about every other player (actually including self)
			//				foreach (NetConnection otherPlayer in server.Connections) {

			//					if (gamer != null && gamer.RemoteUniqueIdentifier != otherPlayer.RemoteUniqueIdentifier) {
			//						continue;
			//					}

			NetDeliveryMethod ndm = NetDeliveryMethod.Unreliable;
			switch (options) {
			case SendDataOptions.Reliable:
				ndm = NetDeliveryMethod.ReliableSequenced;
				break;
			case SendDataOptions.ReliableInOrder:
				ndm = NetDeliveryMethod.ReliableOrdered;
				break;
			case SendDataOptions.InOrder:
				ndm = NetDeliveryMethod.UnreliableSequenced;
				break;
			case SendDataOptions.None:
				ndm = NetDeliveryMethod.Unknown;
				break;
			}
			// send message
			//server.SendToAll (om, player, ndm);
			peer.SendToAll (om, ndm);

			//				}
			//			}				
		}		
Пример #52
0
 public void SendData(byte[] data, SendDataOptions options)
 {
   this.Session.commandQueue.Enqueue(new CommandEvent((ICommand) new CommandSendData(data, 0, data.Length, options, (NetworkGamer) null, this)));
 }