Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void SendPacketToMulti()
        {
            for (int i = 0; i <= m_packetQueueIndex; i++)
            {
                if (i == VNetCommon.NET_PACKET_QUEUE_SIZE)
                {
                    break;
                }
                VNetPacket packet = m_packetOutQueue[i];
                if (packet.header.numMessages == 0)
                {
                    return;
                }

                packet.header.clientUID = VNet.Inst.GetUID();
                packet.header.lastReliablePacketRecvd = -1;
                packet.header.sessionUID      = VNetSession.Inst.GetSessionUID();
                packet.header.identHeader     = VNetManager.Inst.GUIDHeader;
                packet.header.parentEndianess = VNetPlatform.GetEndianValue();

                // End a packet if it is the last one this frame
                if (i == m_packetQueueIndex)
                {
                    packet.EndPacket();
                }

                VNet.Inst.SendOnMultiLink(packet);
                m_clientBandwidth.AddToBandwidth(packet.header.dataLength + VNetPacketHeader.SizeOf(), packet.header.origLength + VNetPacketHeader.SizeOf());
                packet.Clear();
            }
            m_packetQueueIndex = 0;
            ResetTimeToSend();
        }
Ejemplo n.º 3
0
 public void SetOutgoingPacketHeader(VNetPacket packet)
 {
     packet.IP_Port                        = m_ipEndpoint;
     packet.header.clientUID               = VNet.Inst.GetUID();
     packet.header.sessionUID              = VNetSession.Inst.GetSessionUID();
     packet.header.identHeader             = VNetManager.Inst.GUIDHeader;
     packet.header.lastReliablePacketRecvd = m_lastReliableRecvdIndex;
     packet.header.parentEndianess         = VNetPlatform.GetEndianValue();
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        void UpdateLookingForClients()
        {
            // see if we should send a message
            m_lookingForClientsTimer -= VNetTimer.Inst.GetFrameTimeFloat();
            if (m_lookingForClientsTimer > 0.0f)
            {
                return;
            }

            m_lookingForClientsTimer = VNetCommon.NET_HOST_LOBBY_SEND_TIME;

            // Send out a game message
            VNetMessageSessionAvailable session = new VNetMessageSessionAvailable();

            session.UID = VNetSession.Inst.GetSessionUID();
            session.sessionAvaliable = 1;
            session.host             = new VNetSimpleClientData();
            session.host.active      = 1;
            session.host.uid         = VNet.Inst.GetUID();
            session.host.ip          = null;
            session.host.port        = 0;
            session.host.role        = m_hostRole;
            VNetPlatform.FillLocalUsername(ref session.host.name);

            session.numClients = (SByte)VNetSession.Inst.GetNumConnectedClients();

            int i = 0;

            foreach (VNetClient client in VNetSession.Inst.m_clientsByUID.Values)
            {
                session.client[i]        = new VNetLib.VNetSimpleClientData();
                session.client[i].active = 0;
                if (client.GetIsActive())
                {
                    session.client[i].active = 1;
                    session.client[i].ip     = client.GetIP();
                    session.client[i].port   = client.GetPort();
                    session.client[i].name   = client.GetName();
                    session.client[i].role   = client.GetRole();
                }
            }

            VNet.Inst.SendToGlobal(session);
        }
Ejemplo n.º 6
0
 void UpdateUID()
 {
     m_UID = VNetPlatform.GetUID();
 }