Exemplo n.º 1
0
 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
     );
 }
Exemplo n.º 2
0
        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
                );
        }
        internal void DoSendDiscoveryRequest(
            NetworkEndPoint endPoint,
            bool useBroadcast,
            NetDiscoveryRequest request,
            float interval,
            float timeout)
        {
            if (!m_netBase.m_isBound)
            {
                m_netBase.Start();
            }

            m_netBase.LogWrite("Discovery request to " + endPoint);

            if (request == null)
            {
                m_netBase.LogVerbose("Creating discovery request " + m_nextRequestNumber);
                request = new NetDiscoveryRequest(endPoint, m_nextRequestNumber++, useBroadcast, interval, timeout);
                if (m_requests == null)
                {
                    m_requests = new List <NetDiscoveryRequest>();
                }
                m_requests.Add(request);
            }

            string    appIdent = m_netBase.m_config.ApplicationIdentifier;
            NetBuffer data     = new NetBuffer(appIdent.Length + 8);

            // write app identifier
            data.Write(appIdent);

            // write netbase identifier to avoid self-discovery
            data.Write(m_netBase.m_localRndSignature);

            // write request number
            data.Write((ushort)request.Number);

            m_netBase.LogWrite("Discovering " + endPoint.ToString() + "...");
            m_netBase.QueueSingleUnreliableSystemMessage(NetSystemType.Discovery, data, endPoint, useBroadcast);
        }