Exemple #1
0
        public void OnClientsWantsToLeave(VNetMessageLeaveSession leaveRequest)
        {
            VNetMessageLeaveSessionConfirm confirm = new VNetMessageLeaveSessionConfirm();
            VNetClient client = leaveRequest._client;

            confirm.clientUID = client.GetUID();
            client.SendNetMessage(confirm, false);
            client.SendPacketToClient();
            RemoveClient(client);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public void Update(VNetClient host)
 {
     if (host != null && m_timeSyncsRemaining > 0)
     {
         m_nextTimeSync -= VNetTimer.Inst.GetFrameTimeFloat();
         if (m_nextTimeSync <= 0)
         {
             m_nextTimeSync = VNetCommon.NET_TIME_SYNC_WAIT_TIME;
             VNetMessageTimeRequest request = new VNetMessageTimeRequest();
             request.currentTime = VNetTimer.Inst.GetSystemTimeNow();
             host.SendNetMessage(request, false);
         }
     }
 }