コード例 #1
0
        public static NetworkError RegisterClient(TCPServerInfos client, string password)
        {
            if (NetworkingHelper.GetInstance().Server.Room == null)
            {
                return(NetworkError.NoRoomStarted);
            }

            if (NetworkingHelper.GetInstance().Server.Room.Password != "")
            {
                if (NetworkingHelper.GetInstance().Server.Room.Password != password)
                {
                    return(NetworkError.BadPassword);
                }
            }

            if (client == null)
            {
                return(NetworkError.NullClientSent);
            }

            if (_clients == null)
            {
                _clients = new List <TCPServerInfos>();
            }

            _clients.RemoveAll(x => x.ServerIP == client.ServerIP);

            _clients.Add(client);

            return(NetworkError.None);
        }
コード例 #2
0
        public override Packet OnPacketReceive(Packet receivedPacket)
        {
            ClientSendChatMessageEventPacket p = (receivedPacket as ClientSendChatMessageEventPacket);

            string wordToFind = NetworkingHelper.GetInstance().Server.Room.Word;

            if (p.Message.RefactorText() == wordToFind.RefactorText())
            {
                //Show to everyone that he found the word
                p.Message = $"{p.Time.ToShortTimeString()} : {p.Sender} a trouvé le mot";

                ScoreManager.GetInstance().PlayerFoundWord(p.Sender, p.Time);
            }

            EventsManager.OnChatMessageReceive?.Invoke(new Objects.EventArgs.OnChatMessageReceiveEventArgs(
                                                           p.Sender,
                                                           p.Message,
                                                           p.Time)
                                                       );

            ClientsManager.SendPacketToEveryClients(receivedPacket);

            return(new ServerResponsePacket(NetworkError.None));
        }
コード例 #3
0
 public override Packet OnPacketReceive(Packet receivedPacket)
 {
     return new ServerSendRoomPacket(NetworkingHelper.GetInstance().Server.Room);
 }
コード例 #4
0
        public JoinRoomView()
        {
            network = NetworkingHelper.GetInstance();

            InitializeComponent();
        }