示例#1
0
        public virtual void Disconnect()
        {
            Packet packet = new BasicPacket(ClientInfo)
            {
                Disconnect = true
            };

            OnAbort?.Invoke();
            InMatch = false;
            InGame  = false;
            Loaded  = false;

            if (ClientType == ClientType.Host || ClientType == ClientType.Server)
            {
                SendToConnectingClients(packet);
                SendToConnectedClients(packet);
            }
            else
            {
                SendToHost(packet);
            }
        }
示例#2
0
        /// <summary>
        /// Tell peers to start loading game
        /// </summary>
        public virtual void StartLoadingGame()
        {
            if (SendClient == null)
            {
                BasicPacket packet = new BasicPacket(ClientInfo)
                {
                    LoadGame = true
                };

                foreach (ClientInfo client in InMatchClients)
                {
                    packet.PlayerList.Add(client);
                }
                packet.PlayerList.Add(ClientInfo);

                SendToInMatchClients(packet);

                OnLoadGame?.Invoke(packet.PlayerList);
            }
            else
            {
                Logger.Log("Called StartLoadingGame - We are not the Host!", LoggingTarget.Network);
            }
        }
示例#3
0
        public void RequestPlayerList()
        {
            if (ClientType == ClientType.Peer)
            {
                BasicPacket packet = new BasicPacket(ClientInfo)
                {
                    RequestPlayerList = true
                };
                SendToHost(packet);
            }
            else
            {
                List <ClientInfo> playerList = new List <ClientInfo> {
                    ClientInfo
                };

                foreach (ClientInfo clientInfo in ConncetedClients)
                {
                    playerList.Add(clientInfo);
                }

                OnReceivePlayerList?.Invoke(playerList);
            }
        }