Esempio n. 1
0
        private void ProcessReceiveData(CommandReceiveData command)
        {
            // first let's look up the gamer that sent the data
            foreach (NetworkGamer gamer in _allGamers)
            {
                if (gamer.RemoteUniqueIdentifier == command.remoteUniqueIdentifier)
                {
                    command.gamer = gamer;
                }
            }

            // for some reason this is null sometimes
            //  this needs to be looked into instead of the
            //  check below
            if (command.gamer == null)
            {
                return;
            }

            // now we loop through each of our local gamers and add the command
            // to be processed.
            foreach (LocalNetworkGamer localGamer in LocalGamers)
            {
                lock (localGamer.receivedData) {
                    localGamer.receivedData.Enqueue(command);
                }
            }
        }
Esempio n. 2
0
        public int ReceiveData(
            PacketReader data,
            out NetworkGamer sender)
        {
            lock (receivedData) {
                if (receivedData.Count >= 0)
                {
                    data.Reset(0);

                    // take it off the queue
                    CommandReceiveData crd = (CommandReceiveData)receivedData.Dequeue();

                    // lets make sure that we can handle the data
                    if (data.Length < crd.data.Length)
                    {
                        data.Reset(crd.data.Length);
                    }

                    Array.Copy(crd.data, data.Data, data.Length);
                    sender = crd.gamer;
                    return(data.Length);
                }
                else
                {
                    sender = null;
                    return(0);
                }
            }
        }
Esempio n. 3
0
 private void ProcessSendData(CommandSendData command)
 {
   CommandReceiveData commandReceiveData = new CommandReceiveData(command.sender.RemoteUniqueIdentifier, command.data);
   commandReceiveData.gamer = (NetworkGamer) command.sender;
   foreach (LocalNetworkGamer localNetworkGamer in (ReadOnlyCollection<LocalNetworkGamer>) this._localGamers)
     localNetworkGamer.receivedData.Enqueue(commandReceiveData);
 }
Esempio n. 4
0
 public int ReceiveData(byte[] data, int offset, out NetworkGamer sender)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (this.receivedData.Count <= 0)
     {
         sender = (NetworkGamer)null;
         return(0);
     }
     else
     {
         lock (this.receivedData)
         {
             CommandReceiveData local_0 = this.receivedData.Peek();
             if (offset + local_0.data.Length > data.Length)
             {
                 throw new ArgumentOutOfRangeException("data", "The length + offset is greater than parameter can hold.");
             }
             this.receivedData.Dequeue();
             Array.Copy((Array)local_0.data, offset, (Array)data, 0, data.Length);
             sender = local_0.gamer;
             return(data.Length);
         }
     }
 }
Esempio n. 5
0
        private void ProcessSendData(CommandSendData command)
        {
            networkPeer.SendData(command.data, command.options);

            CommandReceiveData crd = new CommandReceiveData(command.sender.RemoteUniqueIdentifier,
                                                            command.data);

            crd.gamer = command.sender;
            foreach (LocalNetworkGamer gamer in _localGamers)
            {
                gamer.receivedData.Enqueue(crd);
            }
        }
Esempio n. 6
0
 private void ProcessReceiveData(CommandReceiveData command)
 {
   foreach (NetworkGamer networkGamer in (ReadOnlyCollection<NetworkGamer>) this._allGamers)
   {
     if (networkGamer.RemoteUniqueIdentifier == command.remoteUniqueIdentifier)
       command.gamer = networkGamer;
   }
   if (command.gamer == null)
     return;
   foreach (LocalNetworkGamer localNetworkGamer in (ReadOnlyCollection<LocalNetworkGamer>) this.LocalGamers)
   {
     lock (localNetworkGamer.receivedData)
       localNetworkGamer.receivedData.Enqueue(command);
   }
 }
Esempio n. 7
0
 public int ReceiveData(PacketReader data, out NetworkGamer sender)
 {
     lock (this.receivedData)
     {
         if (this.receivedData.Count >= 0)
         {
             data.Reset(0);
             CommandReceiveData local_0 = this.receivedData.Dequeue();
             if (data.Length < local_0.data.Length)
             {
                 data.Reset(local_0.data.Length);
             }
             Array.Copy((Array)local_0.data, (Array)data.Data, data.Length);
             sender = local_0.gamer;
             return(data.Length);
         }
         else
         {
             sender = (NetworkGamer)null;
             return(0);
         }
     }
 }
Esempio n. 8
0
		private void ProcessReceiveData(CommandReceiveData command)
		{
			
			// first let's look up the gamer that sent the data
			foreach (NetworkGamer gamer in _allGamers) {
				if (gamer.RemoteUniqueIdentifier == command.remoteUniqueIdentifier)
					command.gamer = gamer;
			}
			
			// for some reason this is null sometimes
			//  this needs to be looked into instead of the
			//  check below
			if (command.gamer == null)
				return;
			
			// now we loop through each of our local gamers and add the command
			// to be processed.
			foreach (LocalNetworkGamer localGamer in LocalGamers) {
				lock (localGamer.receivedData) {
					localGamer.receivedData.Enqueue(command);
				}
			}
			
		}
Esempio n. 9
0
		private void ProcessSendData(CommandSendData command)
		{
			networkPeer.SendData(command.data, command.options);

			NetworkGamer sender;
			CommandReceiveData crd = new CommandReceiveData (command.sender.RemoteUniqueIdentifier,
								command.data);
			crd.gamer = command.sender;
			foreach(LocalNetworkGamer gamer in _localGamers) {
				gamer.receivedData.Enqueue(crd);
			}
		}