public void Unsubscribe() { foreach (var a in Authorized.GetInvocationList()) { Authorized -= (Action)a; } foreach (var a in RoomCreated.GetInvocationList()) { RoomCreated -= (SocketMessage <RoomDTO>)a; } foreach (var a in NewMessageReceived.GetInvocationList()) { NewMessageReceived -= (SocketMessage <MessageDTO>)a; } foreach (var a in RoomParticipated.GetInvocationList()) { RoomParticipated -= (SocketMessage <RoomParticipatedDTO>)a; } foreach (var a in RoomLeft.GetInvocationList()) { RoomLeft -= (SocketMessage <RoomParticipatedDTO>)a; } foreach (var a in FileStatusChanged.GetInvocationList()) { FileStatusChanged -= (SocketMessage <FileStatusDTO>)a; } }
private void CreateGameSession(MatchWaiting <TAccountModel> sender, TAccountModel[] players) { sender.BackToQueue -= ReturnToQueue; sender.OnValidateSuccess -= CreateGameSession; if (RoomCreated != null) { RoomCreated.Invoke(players); } }
private void WaitingForQueryResponse() { Receive <TypedQueryResult <GeneratedAgent> >(msg => { var agents = msg.Result.Values; var message = new RoomCreated(agents.ToList()); _orderedBy.Tell(message); Self.Tell(PoisonPill.Instance); }); }
private void HandleSocketMessage(object sender, MessageEventArgs e) { var message = e.Data; try { var baseMessage = JsonConvert.DeserializeObject <BaseMessage>(message); if (baseMessage.Type == SocketMessageTypes.SuccessfullyAuthorized) { Authorized?.Invoke(); } else if (baseMessage.Type == SocketMessageTypes.RoomCreated) { var response = JsonConvert.DeserializeObject <SocketResponseDTO <RoomDTO> >(message); RoomCreated?.Invoke(response); } else if (baseMessage.Type == SocketMessageTypes.NewMessage) { var response = JsonConvert.DeserializeObject <SocketResponseDTO <MessageDTO> >(message); NewMessageReceived?.Invoke(response); } else if (baseMessage.Type == SocketMessageTypes.RoomParticipated) { var response = JsonConvert.DeserializeObject <SocketResponseDTO <RoomParticipatedDTO> >(message); RoomParticipated?.Invoke(response); } else if (baseMessage.Type == SocketMessageTypes.RoomLeft) { var response = JsonConvert.DeserializeObject <SocketResponseDTO <RoomParticipatedDTO> >(message); RoomLeft?.Invoke(response); } else if (baseMessage.Type == SocketMessageTypes.FileStatusChanged) { var response = JsonConvert.DeserializeObject <SocketResponseDTO <FileStatusDTO> >(message); FileStatusChanged?.Invoke(response); } } catch (Exception ex) { Failed?.Invoke(ex.Message); } }
private void EventReceivedHandler(object sender, EvmChainEventArgs e) { //Debug.Log("Event: " + e.EventName); switch (e.EventName) { case "RoomCreated": { RoomCreatedEventData eventDto = e.DecodeEventDto <RoomCreatedEventData>(); this.eventActions.Enqueue(() => RoomCreated?.Invoke((Address)eventDto.Creator, eventDto.RoomId)); break; } case "PlayerJoined": { PlayerJoinedEventData eventDto = e.DecodeEventDto <PlayerJoinedEventData>(); this.eventActions.Enqueue(() => PlayerJoined?.Invoke(eventDto.RoomId, (Address)eventDto.Player)); break; } case "GameStageChanged": { GameStageChangedEventData eventDto = e.DecodeEventDto <GameStageChangedEventData>(); this.eventActions.Enqueue(() => GameStageChanged?.Invoke(eventDto.RoomId, eventDto.Stage)); break; } case "CurrentPlayerIndexChanged": { CurrentPlayerIndexChangedEventData eventDto = e.DecodeEventDto <CurrentPlayerIndexChangedEventData>(); this.eventActions.Enqueue(() => CurrentPlayerIndexChanged?.Invoke(eventDto.RoomId, eventDto.PlayerIndex, (Address)eventDto.PlayerAddress)); break; } case "PlayerDecisionReceived": { PlayerDecisionReceivedEventData eventDto = e.DecodeEventDto <PlayerDecisionReceivedEventData>(); this.eventActions.Enqueue(() => PlayerDecisionReceived?.Invoke(eventDto.RoomId, eventDto.PlayerIndex, (Address)eventDto.PlayerAddress, eventDto.PlayerDecision)); break; } } }
public void onRoomCreated(RoomCreated roomCreated) { }
protected virtual void OnRoomCreated(Room room) { RoomCreated?.Invoke(room); }
private void RoomCreatedHandler(PacketHeader header, Connection connection, RoomCreated incomingObject) { lock (_user) _user.RoomsHandler?.CreateRoom(incomingObject.Room); }
public void onRoomCreated(RoomCreated roomCreated) { Console.WriteLine("Room " + roomCreated.roomProperties.name); }
private void EventReceivedHandler(object sender, EvmChainEventArgs e) { lock (this.roomIdToRoomEventActionsMap) { switch (e.EventName) { case "RoomCreated": { RoomCreatedEventData eventDto = e.DecodeEventDto<RoomCreatedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, -1, () => RoomCreated?.Invoke((Address) eventDto.Creator, eventDto.RoomId) ); break; } case "PlayerJoined": { PlayerRelatedEventData eventDto = e.DecodeEventDto<PlayerRelatedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => PlayerJoined?.Invoke(eventDto.RoomId, (Address) eventDto.Player) ); break; } case "PlayerLeft": { PlayerRelatedEventData eventDto = e.DecodeEventDto<PlayerRelatedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => PlayerLeft?.Invoke(eventDto.RoomId, (Address) eventDto.Player) ); break; } case "PlayerBetted": { PlayerBettedEventData eventDto = e.DecodeEventDto<PlayerBettedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => PlayerBetted?.Invoke(eventDto.RoomId, (Address) eventDto.Player, eventDto.Bet) ); break; } case "PlayerReadyForNextRoundChanged": { PlayerReadyForNextRoundChangedEventData eventDto = e.DecodeEventDto<PlayerReadyForNextRoundChangedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => PlayerReadyForNextRoundChanged?.Invoke(eventDto.RoomId, (Address) eventDto.Player, eventDto.Ready) ); break; } case "GameStageChanged": { GameStageChangedEventData eventDto = e.DecodeEventDto<GameStageChangedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => GameStageChanged?.Invoke(eventDto.RoomId, eventDto.Stage) ); break; } case "CurrentPlayerIndexChanged": { CurrentPlayerIndexChangedEventData eventDto = e.DecodeEventDto<CurrentPlayerIndexChangedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => CurrentPlayerIndexChanged?.Invoke(eventDto.RoomId, eventDto.PlayerIndex, (Address) eventDto.PlayerAddress) ); break; } case "PlayerDecisionReceived": { PlayerDecisionReceivedEventData eventDto = e.DecodeEventDto<PlayerDecisionReceivedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => PlayerDecisionReceived?.Invoke(eventDto.RoomId, (Address) eventDto.Player, eventDto.PlayerDecision) ); break; } case "GameRoundResultsAnnounced": { GameRoundResultsAnnouncedEventData eventDto = e.DecodeEventDto<GameRoundResultsAnnouncedEventData>(); EnqueueRoomEventAction( eventDto.RoomId, eventDto.Nonce, () => GameRoundResultsAnnounced?.Invoke( eventDto.RoomId, eventDto.DealerOutcome, eventDto.Players.Select(p => (Address) p).ToArray(), eventDto.PlayerOutcome.ToArray()) ); break; } case "Log": { break; } default: throw new ArgumentOutOfRangeException($"Unknown event {e.EventName}"); } } }
public void Bind(Host host) { _host = host; _host.AddHandler((short)LobbyMessages.RoomCreated, (m, c) => { if (RoomCreated != null) { var ds = DataStorage.CreateForRead(m.Body); var roomToken = new Token(); roomToken.ReadFromDs(ds); RoomCreated.Invoke(roomToken); } }); _host.AddHandler((short)LobbyMessages.PlayerLeaved, (m, c) => { if (OnPlayerLeaved != null) { var ds = DataStorage.CreateForRead(m.Body); var playerToken = new Token(); playerToken.ReadFromDs(ds); OnPlayerLeaved.Invoke(playerToken); } }); _host.AddHandler((short)LobbyMessages.SuccesfullyLeaved, (m, c) => { if (OnLeave != null) { OnLeave.Invoke(); } }); _host.AddHandler((short)LobbyMessages.PlayerJoined, (m, c) => { if (OnPlayerJoined != null) { var ds = DataStorage.CreateForRead(m.Body); var playerToken = new Token(); playerToken.ReadFromDs(ds); OnPlayerJoined.Invoke(playerToken); } }); _host.AddHandler((short)LobbyMessages.SuccesfullyJoined, (m, c) => { if (OnJoin != null) { OnJoin.Invoke(); } }); _host.AddHandler((short)LobbyMessages.GameStarted, (m, c) => { if (OnGameStarted != null) { var ds = DataStorage.CreateForRead(m.Body); _roomToken = new Token(); _roomToken.ReadFromDs(ds); OnGameStarted.Invoke(); } }); _host.AddHandler((short)LobbyMessages.GetRoomsResponse, (m, c) => { if (OnRoomInfoRecieved != null) { var roomTokens = new List <Token>(); roomTokens.FillDeserialize(m.Body); OnRoomInfoRecieved.Invoke(roomTokens); } }); }
void IChatServiceCallback.RoomCreated(ChatRoom room) { _rooms.Add(room.Id, room); _eventDispatcher.Add(() => RoomCreated.SafeInvoke(room)); }
private static void OnRoomCreated(RoomManager roomManager, Room room) { RoomCreated?.Invoke(roomManager, new RoomEventArgs(room)); }
public void Apply(RoomCreated aggregateEvent) { RoomNumber = aggregateEvent.RoomNumber; }