public void Encode_basic_ok() { var message = new ConnectionRequestAccepted(); message.NoBatch = true; message.systemAddress = new IPEndPoint(IPAddress.Loopback, 19132); message.systemAddresses = new IPEndPoint[20]; message.systemAddresses[0] = new IPEndPoint(IPAddress.Loopback, 19132); message.incomingTimestamp = 12345; message.serverTimestamp = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond; for (int i = 1; i < 20; i++) { message.systemAddresses[i] = new IPEndPoint(IPAddress.Any, 19132); } var datagrams = Datagram.CreateDatagrams(message, 1664, new RakSession(null, null, IPEndPoint.Parse("127.0.0.1"), 1664)); foreach (Datagram datagram in datagrams) { var buffer = new byte[1600]; long length = datagram.GetEncoded(ref buffer); Assert.AreNotEqual(length, buffer.Length); } }
public void SendPackage(Player player, IPEndPoint senderEndpoint, List <Package> messages, int mtuSize, ref int reliableMessageNumber, Reliability reliability = Reliability.Reliable) { if (messages.Count == 0) { return; } Datagram.CreateDatagrams(messages, mtuSize, ref reliableMessageNumber, senderEndpoint, SendDatagram); foreach (var message in messages) { if (!player.IsBot) { Thread.Sleep(5); } if (message is InternalPing) { _latency = (_latency * 9 + message.Timer.ElapsedMilliseconds) / 10; } TraceSend(message); message.PutPool(); } }
public void SendPackage(Player player, List <Package> messages, int mtuSize, ref int reliableMessageNumber, Reliability reliability = Reliability.Reliable) { if (messages.Count == 0) { return; } PlayerNetworkSession session; if (_playerSessions.TryGetValue(player.EndPoint, out session)) { Datagram.CreateDatagrams(messages, mtuSize, ref reliableMessageNumber, session, SendDatagram); foreach (var message in messages) { Thread.Sleep(1); // Seems to be needed regardless :-( if (message is InternalPing) { ServerInfo.Latency = (ServerInfo.Latency * 9 + message.Timer.ElapsedMilliseconds) / 10; } TraceSend(message); message.PutPool(); } } }
public async Task SendPacketAsync(RakSession session, Packet message) { foreach (Datagram datagram in Datagram.CreateDatagrams(message, session.MtuSize, session)) { await SendDatagramAsync(session, datagram); } message.PutPool(); }
public void SendPackage(PlayerNetworkSession session, Package message) { foreach (var datagram in Datagram.CreateDatagrams(message, session.MtuSize, session)) { SendDatagram(session, datagram); } message.PutPool(); }
public void SendPackage(Package message, short mtuSize, ref int reliableMessageNumber) { if (message == null) { return; } TraceSend(message); Datagram.CreateDatagrams(message, mtuSize, ref reliableMessageNumber, Session, SendDatagram); }
public void SendPackage(Package message, short mtuSize, ref int reliableMessageNumber) { if (message == null) { return; } TraceSend(message); foreach (var datagram in Datagram.CreateDatagrams(message, mtuSize, Session)) { SendDatagram(Session, datagram); } }
public void SendPackage(IPEndPoint senderEndpoint, List <Package> messages, short mtuSize, ref int datagramSequenceNumber, ref int reliableMessageNumber, Reliability reliability = Reliability.Reliable) { if (messages.Count == 0) { return; } foreach (var message in messages) { TraceSend(message); } Datagram.CreateDatagrams(messages, mtuSize, ref reliableMessageNumber, senderEndpoint, SendDatagram); }
public void SendPackage(List <Package> messages, short mtuSize, ref int reliableMessageNumber) { if (messages.Count == 0) { return; } foreach (var message in messages) { TraceSend(message); } Datagram.CreateDatagrams(messages, mtuSize, ref reliableMessageNumber, Session, SendDatagram); }
public void SendPackage(Player player, Package message, int mtuSize, ref int reliableMessageNumber, Reliability reliability = Reliability.Reliable) { if (message == null) { return; } PlayerNetworkSession session; if (_playerSessions.TryGetValue(player.EndPoint, out session)) { Datagram.CreateDatagrams(message, mtuSize, ref reliableMessageNumber, session, SendDatagram); message.PutPool(); } Thread.Sleep(1); // Really important to slow down speed a bit }
public void SendPackage(Player player, Package message, int mtuSize, Reliability reliability = Reliability.Reliable) { if (message == null) return; PlayerNetworkSession session; if (_playerSessions.TryGetValue(player.EndPoint, out session)) { foreach (var datagram in Datagram.CreateDatagrams(message, mtuSize, session)) { SendDatagram(session, datagram); } TraceSend(message); message.PutPool(); //Thread.Sleep(1); // Really important to slow down speed a bit } }