Example #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();
        }
Example #2
0
        public VNetClientPing(VNetClient client)
        {
            m_client = client;
            m_times  = new double[VNetCommon.NET_CLIENT_PING_QUEUE_LENGTH];
            Reset();

            VNetDispatch.RegisterListenerInst <VNetMessagePingClient>(OnPing);
            VNetDispatch.RegisterListenerInst <VNetMessagePongClient>(OnPong);
        }
Example #3
0
 public void SetHostInfo(UInt64 clientID, int hostRole)
 {
     if (LocalIsHost())
     {
         VNetDispatch.UnregisterListenerInst <VNetMessageJoinSession>(OnClientJoinRequest);
     }
     m_hostUID  = clientID;
     m_hostRole = hostRole;
     if (LocalIsHost())
     {
         m_lookingForClientsTimer = 0;
         VNetDispatch.RegisterListenerInst <VNetMessageJoinSession>(OnClientJoinRequest);
     }
 }
Example #4
0
        void UnregisterListeners()
        {
            // Net session messages
            VNetDispatch.UnregisterListenerInst <VNetMessageAcceptClient>(m_netSession.OnAcceptClientJoinRequest);
            VNetDispatch.UnregisterListenerInst <VNetMessageNewClient>(m_netSession.OnNewClient);
            VNetDispatch.UnregisterListenerInst <VNetMessageLeaveSession>(m_netSession.OnClientsWantsToLeave);
            VNetDispatch.UnregisterListenerInst <VNetMessageLeaveSessionConfirm>(m_netSession.OnClientLeaveConfirm);

            // Net time
            VNetDispatch.UnregisterListenerInst <VNetMessageTimeRequest>(m_netSession.m_netTime.OnTimeRequest);
            VNetDispatch.UnregisterListenerInst <VNetMessageTimeReturn>(m_netSession.m_netTime.OnTimeReturn);

            // New games
            VNetDispatch.UnregisterListenerInst <VNetMessageSessionAvailable>(m_availableSessions.AddOrUpdateSession);
        }
Example #5
0
 public VNetDispatch()
 {
     Inst       = this;
     m_register = new Dictionary <uint, VNetDispatchRegistryBase>();
 }