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(); }
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); }
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); } }
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); }
public VNetDispatch() { Inst = this; m_register = new Dictionary <uint, VNetDispatchRegistryBase>(); }