private void NotifyPlayersAboutUpdateRoom(ClientObject client, RoomObject room, UpdateRoomType type) { var response = new UpdateRoomResponse(); if (type == UpdateRoomType.UpdatePlayers) { response.Type = UpdateRoomType.UpdatePlayers; response.Player = client.Player; response.Selector = room.Selector.Player; if (room.Respondent != null) { response.Respondent = room.Respondent.Player; } } else { response.Type = UpdateRoomType.UpdateTable; room.Game.StopAnswerButtonClickTimer(); } string packetResponse = JsonConvert.SerializeObject(response); //после отправки удаляем респондента room.Respondent = null; room.SendMessageToAllClients(packetResponse); }
//отправка игрокам комнаты информацию об обновлении комнаты private void NotifyPlayersAboutUpdateRooms(RoomObject room) { var responeForPlayers = new GetRoomInfoResponse(); responeForPlayers.Players = room.GetAllPlayers(); string packetResponseForPlayers = JsonConvert.SerializeObject(responeForPlayers); room.SendMessageToAllClients(packetResponseForPlayers); }
public void Excecute(ClientObject client, ServerObject server, RoomObject room, string packet = "") { room.Game.list.Clear(); room.Game.listClickButton.Clear(); room.Respondents.Clear(); Console.WriteLine("Show question"); var request = JsonConvert.DeserializeObject <ShowQuestionRequest>(packet); var response = new ShowQuestionResponse(); response.QuestionId = request.QuestionId; room.Game.CurrentQuestionId = request.QuestionId; string packetResponse = JsonConvert.SerializeObject(response); room.SendMessageToAllClients(packetResponse); //останавливаем таймер когда игрок выбрал вопрос room.Game.StopSelectQuestionTimer(); //запускаем таймер для нажания на кнопку "ответ" room.Game.StartAnswerButtonClickTimer(); }