Exemplo n.º 1
0
        protected NetBase(NetConfiguration config)
        {
            Debug.Assert(config != null, "Config must not be null");
            if (string.IsNullOrEmpty(config.ApplicationIdentifier))
                throw new ArgumentException("Must set ApplicationIdentifier in NetConfiguration!");
            m_config = config;
            m_receiveBuffer = new NetBuffer(config.ReceiveBufferSize);
            m_sendBuffer = new NetBuffer(config.SendBufferSize);
            m_senderRemote = (EndPoint)new IPEndPoint(IPAddress.Any, 0);
            m_statistics = new NetBaseStatistics();
            m_receivedMessages = new NetQueue<IncomingNetMessage>(4);
            m_scratchBuffer = new NetBuffer(32);
            m_bindLock = new object();
            m_discovery = new NetDiscovery(this);

            m_randomIdentifier = new byte[8];
            NetRandom.Instance.NextBytes(m_randomIdentifier);

            m_unsentOutOfBandMessages = new NetQueue<NetBuffer>();
            m_unsentOutOfBandRecipients = new NetQueue<IPEndPoint>();
            m_susmQueue = new Queue<SUSystemMessage>();

            // default enabled message types
            m_enabledMessageTypes =
                NetMessageType.Data | NetMessageType.StatusChanged | NetMessageType.ServerDiscovered |
                NetMessageType.DebugMessage | NetMessageType.Receipt;
        }
Exemplo n.º 2
0
        protected NetBase(NetConfiguration config)
        {
            Debug.Assert(config != null, "Config must not be null");
            if (string.IsNullOrEmpty(config.ApplicationIdentifier))
            {
                throw new ArgumentException("Must set ApplicationIdentifier in NetConfiguration!");
            }
            m_config           = config;
            m_receiveBuffer    = new NetBuffer(config.ReceiveBufferSize);
            m_sendBuffer       = new NetBuffer(config.SendBufferSize);
            m_senderRemote     = (EndPoint) new IPEndPoint(IPAddress.Any, 0);
            m_statistics       = new NetBaseStatistics();
            m_receivedMessages = new NetQueue <IncomingNetMessage>(4);
            m_scratchBuffer    = new NetBuffer(32);
            m_bindLock         = new object();
            m_discovery        = new NetDiscovery(this);
            m_heartbeatCounter = new NetFrequencyCounter(3.0f);

            m_randomIdentifier = new byte[8];
            NetRandom.Instance.NextBytes(m_randomIdentifier);

            m_unsentOutOfBandMessages   = new NetQueue <NetBuffer>();
            m_unsentOutOfBandRecipients = new NetQueue <IPEndPoint>();
            m_susmQueue = new Queue <SUSystemMessage>();

            // default enabled message types
            m_enabledMessageTypes =
                NetMessageType.Data | NetMessageType.StatusChanged | NetMessageType.ServerDiscovered |
                NetMessageType.DebugMessage | NetMessageType.Receipt;
        }
        protected NetBase(NetConfiguration config)
        {
            Debug.Assert(config != null, "Config must not be null");
            if (string.IsNullOrEmpty(config.ApplicationIdentifier))
            {
                throw new ArgumentException("Must set ApplicationIdentifier in NetConfiguration!");
            }
            m_config        = config;
            m_receiveBuffer = new NetBuffer(config.ReceiveBufferSize);
            m_sendBuffer    = new NetBuffer(config.SendBufferSize);
            //by WuNan @2016/09/28 14:26:34
                        #if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR
            if (uLink.NetworkUtility.IsSupportIPv6())
            {
                m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.IPv6Any, 0);
            }
            else
            {
                m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.Any, 0);
            }
                        #else
            m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.Any, 0);
                        #endif
            m_statistics       = new NetBaseStatistics();
            m_receivedMessages = new NetQueue <IncomingNetMessage>(4);
            m_tempBuffer       = new NetBuffer(256);
            m_discovery        = new NetDiscovery(this);
            m_heartbeatCounter = new NetFrequencyCounter(3.0f);

            m_localRndSignature = new byte[NetConstants.SignatureByteSize];
            NetRandom.Instance.NextBytes(m_localRndSignature);

            m_unsentOutOfBandMessages   = new NetQueue <NetBuffer>();
            m_unsentOutOfBandRecipients = new NetQueue <NetworkEndPoint>();
            m_susmQueue = new Queue <SUSystemMessage>();

            // default enabled message types
            m_enabledMessageTypes =
                NetMessageType.Data | NetMessageType.StatusChanged;
        }