Example #1
0
        private void SendDatagram(PlayerNetworkSession session, Datagram datagram)
        {
            if (datagram.MessageParts.Count == 0)
            {
                datagram.PutPool();
                Log.WarnFormat("Failed to resend #{0}", datagram.Header.datagramSequenceNumber.IntValue());
                return;
            }

            datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);

            datagram.TransmissionCount++;

            byte[] data = datagram.Encode();

            datagram.Timer.Restart();

            if (!session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber.IntValue(), datagram))
            {
                Log.Warn(string.Format("Datagram sequence unexpectedly existed in the ACK/NAK queue already {0}", datagram.Header.datagramSequenceNumber.IntValue()));
            }
            //datagram.PutPool();

            lock (session.SyncRoot)
            {
                SendData(data, session.EndPoint);
            }
        }
Example #2
0
        private void SendDatagram(PlayerNetworkSession session, Datagram datagram)
        {
            if (datagram.MessageParts.Count != 0)
            {
                datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref Session.DatagramSequenceNumber);
                byte[] data = datagram.Encode();

                datagram.Timer.Restart();
                SendData(data, _serverEndpoint);
            }
        }
Example #3
0
        private void SendDatagram(IPEndPoint senderEndpoint, Datagram datagram, bool isResend)
        {
            if (datagram.MessageParts.Count != 0)
            {
                Log.Debug("<\tSend Datagram #" + datagram.Header.datagramSequenceNumber.IntValue());
                byte[] data = datagram.Encode();

                datagram.Timer.Restart();
                SendData(data, senderEndpoint);
            }
        }
Example #4
0
        internal void SendDatagram(PlayerNetworkSession session, Datagram datagram)
        {
            if (datagram.MessageParts.Count == 0)
            {
                datagram.PutPool();
                Log.WarnFormat("Failed to resend #{0}", datagram.Header.datagramSequenceNumber.IntValue());
                return;
            }

            if (datagram.TransmissionCount > 10)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.WarnFormat("TIMEOUT, Retransmission count remove from ACK queue #{0} Type: {2} (0x{2:x2}) for {1}",
                                   datagram.Header.datagramSequenceNumber.IntValue(),
                                   session.Username,
                                   datagram.FirstMessageId);
                }

                datagram.PutPool();

                Interlocked.Increment(ref ServerInfo.NumberOfFails);
                return;
            }

            datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);
            datagram.TransmissionCount++;

            byte[] data = datagram.Encode();

            datagram.Timer.Restart();

            if (!session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber.IntValue(), datagram))
            {
                Log.Warn(string.Format("Datagram sequence unexpectedly existed in the ACK/NAK queue already {0}", datagram.Header.datagramSequenceNumber.IntValue()));
            }

            lock (session.SyncRoot)
            {
                SendData(data, session.EndPoint);
                Thread.Sleep(12);
            }
        }
Example #5
0
        private void SendDatagram(IPEndPoint senderEndpoint, Datagram datagram)
        {
            PlayerNetworkSession session;

            if (_playerSessions.TryGetValue(senderEndpoint, out session))
            {
                if (datagram.MessageParts.Count != 0)
                {
                    //if (!isResend)
                    {
                        datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);
                    }

                    byte[] data = datagram.Encode();

                    SendData(data, senderEndpoint, session.SyncRoot);

                    datagram.TransmissionCount++;
                    datagram.Timer.Restart();

                    if (!session.Player.IsBot)
                    {
                        session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber, datagram);
                    }
                }

                if (session.Player.IsBot)
                {
                    foreach (MessagePart part in datagram.MessageParts)
                    {
                        part.PutPool();
                    }

                    datagram.PutPool();
                }
            }
        }
Example #6
0
		private void SendDatagram(PlayerNetworkSession session, Datagram datagram)
		{
			if (datagram.MessageParts.Count == 0)
			{
				datagram.PutPool();
				Log.WarnFormat("Failed to resend #{0}", datagram.Header.datagramSequenceNumber.IntValue());
				return;
			}

			datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);

			datagram.TransmissionCount++;

			byte[] data = datagram.Encode();

			datagram.Timer.Restart();

			if (!session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber.IntValue(), datagram))
			{
				Log.Warn(string.Format("Datagram sequence unexpectedly existed in the ACK/NAK queue already {0}", datagram.Header.datagramSequenceNumber.IntValue()));
			}

			lock (session.SyncRoot)
			{
				SendData(data, session.EndPoint);
			}
		}
Example #7
0
        private void SendDatagram(IPEndPoint senderEndpoint, Datagram datagram)
        {
            PlayerNetworkSession session;
            if (_playerSessions.TryGetValue(senderEndpoint, out session))
            {
                if (datagram.MessageParts.Count != 0)
                {
                    //if (!isResend)
                    {
                        datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);
                    }

                    byte[] data = datagram.Encode();

                    SendData(data, senderEndpoint, session.SyncRoot);

                    datagram.TransmissionCount++;
                    datagram.Timer.Restart();

                    if (!session.Player.IsBot)
                    {
                        session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber, datagram);
                    }
                }

                if (session.Player.IsBot)
                {
                    foreach (MessagePart part in datagram.MessageParts)
                    {
                        part.PutPool();
                    }

                    datagram.PutPool();
                }
            }
        }
Example #8
0
        private void SendDatagram(PlayerNetworkSession session, Datagram datagram)
        {
            if (datagram.MessageParts.Count != 0)
            {
                datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref Session.DatagramSequenceNumber);
                byte[] data = datagram.Encode();

                datagram.Timer.Restart();
                SendData(data, _serverEndpoint);
            }
        }
Example #9
0
        private void SendDatagram(IPEndPoint senderEndpoint, Datagram datagram, bool isResend)
        {
            if (datagram.MessageParts.Count != 0)
            {
                Log.Debug("<\tSend Datagram #" + datagram.Header.datagramSequenceNumber.IntValue());
                byte[] data = datagram.Encode();

                datagram.Timer.Restart();
                SendData(data, senderEndpoint);
            }
        }
Example #10
0
        private void SendDatagram(IPEndPoint senderEndpoint, Datagram datagram)
        {
            PlayerNetworkSession session;
            if (_playerSessions.TryGetValue(senderEndpoint, out session))
            {
                if (datagram.MessageParts.Count != 0)
                {
                    //if (!isResend)
                    {
                        datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);
                    }

                    byte[] data = datagram.Encode();

                    if (!session.Player.IsBot)
                    {
                        if (!session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber.IntValue(), datagram))
                        {
                            Log.Warn(string.Format("Datagram sequence unexpectedly existed in the ACK/NAK queue already {0}", datagram.Header.datagramSequenceNumber.IntValue()));
                        }
                    }

                    datagram.TransmissionCount++;

                    SendData(data, senderEndpoint, session.SyncRoot);

                    datagram.Timer.Restart();
                }

                if (session.Player.IsBot)
                {
                    foreach (MessagePart part in datagram.MessageParts)
                    {
                        part.PutPool();
                    }

                    datagram.PutPool();
                }
            }
        }
Example #11
0
        private void SendDatagram(PlayerNetworkSession session, Datagram datagram, bool updateCounter)
        {
            if (datagram.MessageParts.Count == 0)
            {
                datagram.PutPool();
                Log.WarnFormat("Failed to resend #{0}", datagram.Header.datagramSequenceNumber.IntValue());
                return;
            }

            if (updateCounter)
            {
                datagram.Header.datagramSequenceNumber = Interlocked.Increment(ref session.DatagramSequenceNumber);
            }

            datagram.TransmissionCount++;

            byte[] data = datagram.Encode();

            datagram.Timer.Restart();

            if (!session.WaitingForAcksQueue.TryAdd(datagram.Header.datagramSequenceNumber.IntValue(), datagram))
            {
                Log.Warn(string.Format("Datagram sequence unexpectedly existed in the ACK/NAK queue already {0}", datagram.Header.datagramSequenceNumber.IntValue()));
            }

            lock (session.SyncRoot)
            {
                SendData(data, session.EndPoint, session.SyncRoot);
                int sndDelay = (int) (50f/4f);
                sndDelay = sndDelay + (20*(1/(datagram.Header.datagramSequenceNumber.IntValue() + 1)));
                //Thread.Sleep(sndDelay); // Really important to slow down speed a bit
            }
        }