internal static void SendPing(NetBase netBase, IPEndPoint toEndPoint, double now) { ushort nowEnc = NetTime.Encoded(now); NetBuffer buffer = netBase.m_scratchBuffer; buffer.Reset(); buffer.Write(nowEnc); netBase.SendSingleUnreliableSystemMessage( NetSystemType.Ping, buffer, toEndPoint, false ); }
internal static void QueuePing(NetBase netBase, IPEndPoint toEndPoint, double now) { ushort nowEnc = NetTime.Encoded(now); NetBuffer buffer = netBase.m_scratchBuffer; buffer.Reset(); buffer.Write(nowEnc); netBase.QueueSingleUnreliableSystemMessage( NetSystemType.Ping, buffer, toEndPoint, false ); }
public static bool SafeHeartbeat(NetBase net) { if (net == null) { return(false); } try { net.Heartbeat(); } catch (NetException ex) { if (ex.InnerException is SecurityException) { Log.Error(LogFlags.Socket, ex.Message, " because of security. Make sure your running a policy server on the other end. If this only happens once, you can ignore it or avoid it by prefetching from policy server using Security.PrefetchSocketPolicy. ", ex); return(true); // TODO: should we really try again? } var sex = ex.InnerException as SocketException; if (IsSocketErrorPermanent(sex)) { Log.Warning(LogFlags.Socket, "Socket error is interpreted as the network is shutdown: ", ex.InnerException); return(false); } if (sex != null) { Log.Error(LogFlags.Socket, ex.Message, ": [socket error = ", sex.SocketErrorCode, ", code = ", sex.ErrorCode, "] ", ex.InnerException); } else { Log.Error(LogFlags.Socket, ex.Message, ": ", ex.InnerException); } } catch (Exception ex) { Log.Error(LogFlags.Socket, ex); } return(true); }
internal NetConnection(NetBase owner, IPEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData) { m_owner = owner; m_remoteEndPoint = remoteEndPoint; m_localHailData = localHailData; m_remoteHailData = remoteHailData; m_futureClose = double.MaxValue; m_throttleDebt = owner.m_config.m_throttleBytesPerSecond; // slower start m_statistics = new NetConnectionStatistics(this, 1.0f); m_unsentMessages = new NetQueue <OutgoingNetMessage>(6); m_lockedUnsentMessages = new NetQueue <OutgoingNetMessage>(3); m_status = NetConnectionStatus.Connecting; // to prevent immediate removal on heartbeat thread InitializeReliability(); InitializeFragmentation(); InitializeStringTable(); //InitializeCongestionControl(32); }
internal NetConnection(NetBase owner, IPEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData) { m_owner = owner; m_remoteEndPoint = remoteEndPoint; m_localHailData = localHailData; m_remoteHailData = remoteHailData; m_futureClose = double.MaxValue; m_throttleDebt = owner.m_config.m_throttleBytesPerSecond; // slower start m_statistics = new NetConnectionStatistics(this, 1.0f); m_unsentMessages = new NetQueue<OutgoingNetMessage>(6); m_lockedUnsentMessages = new NetQueue<OutgoingNetMessage>(3); m_status = NetConnectionStatus.Connecting; // to prevent immediate removal on heartbeat thread InitializeReliability(); InitializeFragmentation(); InitializeStringTable(); //InitializeCongestionControl(32); }
internal NetConnection(NetBase owner, NetworkEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData, byte[] remoteRndSignature, int remoteRndSeqNr) { m_owner = owner; m_remoteEndPoint = remoteEndPoint; m_localHailData = localHailData; m_remoteHailData = remoteHailData; m_remoteRndSignature = remoteRndSignature; m_remoteRndSeqNr = remoteRndSeqNr; m_localRndSeqNr = NetRandom.Instance.Next(0, NetConstants.NumSequenceNumbers - 1); m_futureClose = double.MaxValue; m_throttleDebt = owner.m_config.m_throttleBytesPerSecond; // slower start m_statistics = new NetConnectionStatistics(this); m_status = NetConnectionStatus.Connecting; // to prevent immediate removal on heartbeat thread ResetReliability(); InitializeReliability(); InitializeFragmentation(); InitializeStringTable(); //InitializeCongestionControl(32); }
internal NetDiscovery(NetBase netBase) { m_nextRequestNumber = 1; m_netBase = netBase; m_requests = null; }