void UpdateJoiningSession() { VNet.Inst.m_availableSessions.RemoveStaleSessions(); if (m_sessionUID == VNetCommon.NET_SESSION_INVALID_UID) { return; } // Potentially check for timeout m_attemptingToJoinTimer -= VNetTimer.Inst.GetFrameTimeFloat(); if (m_attemptingToJoinTimer > 0) { return; } m_attemptingToJoinTimer = VNetCommon.NET_CLIENT_CONNECTION_TIME; if (m_attemptingToJoinSession == null) { return; } // send a message to join VNetMessageJoinSession jsm = new VNetMessageJoinSession(); jsm.sessionUID = m_attemptingToJoinSession.sessionUID; jsm.role = m_attemptingToJoinRole; VNetPlatform.FillLocalUsername(ref jsm.userName); // Send VNet.Inst.SendToGlobal(jsm); }
public override VNetMessage Clone() { VNetMessageJoinSession clone = (VNetMessageJoinSession)base.Clone(); clone.sessionUID = sessionUID; clone.role = role; clone.userName = userName; return(clone); }
public void OnClientJoinRequest(VNetMessageJoinSession joinRequest) { // If i'm not the host, ignore this if (LocalIsHost() == false) { return; } // If this is for a separate session, ignore UInt64 sessionUID = VNetSession.Inst.GetSessionUID(); if (joinRequest.sessionUID != sessionUID) { return; } // Could be a dup, ignore if if that's the case if (VNetSession.Inst.GetClientByUID(joinRequest._packet.header.clientUID) != null) { return; } // Add this client VNetMessageNewClient nmc = new VNetMessageNewClient(); nmc.clientData = new VNetSimpleClientData(); nmc.clientData.active = 1; nmc.clientData.ip = joinRequest._packet.IP_Port.Address; nmc.clientData.port = joinRequest._packet.IP_Port.Port; nmc.clientData.uid = joinRequest._packet.header.clientUID; nmc.clientData.name = joinRequest.userName; nmc.clientData.role = joinRequest.role; nmc.sessionUID = sessionUID; VNet.Inst.SendToLobby(nmc, true); // Add the client to the local list VNetClient client = VNetSession.Inst.AddClient(joinRequest._packet.header.clientUID, joinRequest._packet.IP_Port); client.SetName(joinRequest.userName); client.SetRole(joinRequest.role); // Accept this client VNetMessageAcceptClient ac = new VNetMessageAcceptClient(); ac.clientUID = client.GetUID(); ac.sessionUID = sessionUID; ac.role = joinRequest.role; client.SendNetMessage(ac, true); }