public LobbyScreenRegular(JSON_Classes.Room room)
 {
     InitializeComponent();
     RoomNameLabel.Text        = room.Metadata.name;
     MaxPlayersLabel.Text      = String.Format(MaxPlayersLabel.Text, room.Metadata.MaxPlayers);
     QuestionCountLabel.Text   = String.Format(QuestionCountLabel.Text, room.Metadata.QuestionCount);
     TimePerQuestionLabel.Text = String.Format(TimePerQuestionLabel.Text, room.Metadata.AnswerTimeout);
     PlayerListBox.DataSource  = room.Players;
     this.room  = room;
     loopThread = new Thread(updateLoop);
     loopThread.Start();
 }
Пример #2
0
        private void CreateLobbyButton_Click(object sender, EventArgs e)
        {
            var form = new LobbyDetailsForm();

            this.Hide();
            form.ShowDialog();
            var request = new JSON_Classes.CreateRoomRequest {
                Name = form.Name, MaxUsers = form.MaxUsers, QuestionCount = form.QuestionCount, TimePerQuestion = form.TimePerQuestion
            };

            byte[] message = GlobalHelpers.CreateMessage("116", request);
            ClientSocket.client.Send(message);
            byte[] response  = new byte[1024];
            int    bytesRead = ClientSocket.client.Receive(response);

            Array.Resize <byte>(ref response, bytesRead);
            if (GlobalHelpers.GetCode(response) == "216")
            {
                var result   = MessagePack.MessagePackSerializer.Deserialize <JSON_Classes.CreateRoomResponse>(GlobalHelpers.GetMsgpack(response));
                var room     = new JSON_Classes.Room();
                var metadata = new JSON_Classes.RoomData();
                metadata.IsActive      = 0;
                metadata.id            = result.Id;
                metadata.name          = request.Name;
                metadata.MaxPlayers    = request.MaxUsers;
                metadata.QuestionCount = request.QuestionCount;
                metadata.AnswerTimeout = request.TimePerQuestion;
                room.Players           = new[] { username };
                room.Metadata          = metadata;
                var gameLobby = new LobbyScreenAdmin(room);
                this.Hide();
                gameLobby.ShowDialog();
                this.Show();
            }
            else
            {
                MessageBox.Show("Error Creating Lobby!");
                this.Close();
            }
        }