Beispiel #1
0
        public VNet()
        {
            Inst          = this;
            m_netDispatch = new VNetDispatch();
            m_netTimer    = new VNetTimer();

            // Initialize client and multi links
            m_clientLink = UnityEngine.Transform.FindObjectOfType <VNetSockClientLink>();
            if (m_clientLink == null)
            {
                GameObject newObj = new GameObject("VNetSockets");
                GameObject.DontDestroyOnLoad(newObj);
                m_clientLink = newObj.AddComponent <VNetSockClientLink>();
                m_multiLink  = newObj.AddComponent <VNetSockMultiLink>();
            }
            else
            {
                m_multiLink = m_clientLink.GetComponent <VNetSockMultiLink>();
            }

            // m_clientLink = new VNetSockClientLink();
            // m_multiLink = new VNetSockMultiLink();

            m_multicastClient   = new VNetClient();
            m_availableSessions = new VNetAvailableSessions();
            m_netSession        = new VNetSession();



            RegisterListeners();
        }
Beispiel #2
0
        static public UInt64 GenerateUIDInEditor()
        {
            VNetTimer timer       = new VNetTimer();
            double    currentTime = timer.GetSystemTimeNow();

            timer = null;

            UInt64 clientID = VNetPlatform.GetUID();
            double seed     = (new Random()).NextDouble();


            UInt64 timeRe = BitConverter.ToUInt64(BitConverter.GetBytes(currentTime), 0);
            UInt64 seedRe = BitConverter.ToUInt64(BitConverter.GetBytes(seed), 0);

            return((clientID ^ timeRe) + seedRe);
        }
Beispiel #3
0
 public VNetTimer()
 {
     Inst = this;
     Load();
 }