private void ContractEventReceived(object sender, EvmChainEventArgs e)
 {
     Debug.LogFormat("Received smart contract event: " + e.EventName);
     if (e.EventName == "OnTileMapStateUpdate")
     {
         OnTileMapStateUpdateEvent onTileMapStateUpdateEvent = e.DecodeEventDto <OnTileMapStateUpdateEvent>();
         Debug.LogFormat("OnTileMapStateUpdate event data: " + onTileMapStateUpdateEvent.State);
     }
 }
        private void EventReceivedHandler(object sender, EvmChainEventArgs e)
        {
            if (e.EventName != "OnTileMapStateUpdate")
            {
                return;
            }

            OnTileMapStateUpdateEvent onTileMapStateUpdateEvent = e.DecodeEventDTO <OnTileMapStateUpdateEvent>();
            JsonTileMapState          jsonTileMapState          = JsonUtility.FromJson <JsonTileMapState>(onTileMapStateUpdateEvent.State);

            this.eventActions.Enqueue(() =>
            {
                TileMapStateUpdated?.Invoke(jsonTileMapState);
            });
        }
Beispiel #3
0
    private async void ContractEventReceived(object sender, EvmChainEventArgs e)
    {
        Debug.LogFormat("Received smart contract event: " + e.EventName);
        if (e.EventName == "OnBet")
        {
            await UpdatePlayers();

            // Debug.Log("On evenbbbbbbbbbbbb");
            // OnBetEvent evt = e.DecodeEventDTO<OnBetEvent>();
            // Debug.Log(evt);
            // Debug.Log("frommmmmmmmmmmmmmm" + evt.From);
            // Debug.Log("bettttttttttttttttttttttt" + evt.BetNumber);
            // Debug.Log("On eventaaaaaaaaaaaaaaaaaaaaaaaaa");
        }
    }
    /// <summary>
    /// This method receives raw EVM events from the DAppChain.
    /// Add decoding of your own events here.
    /// </summary>
    /// <remarks>
    /// Events are not dispatched immediately.
    /// Instead, they are queued to allow dispatching them when it is appropriate.
    /// </remarks>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void EventReceivedHandler(object sender, EvmChainEventArgs e)
    {
        switch (e.EventName)
        {
        case "ValueChanged": {
            ValueChangedEventData eventDto = e.DecodeEventDto <ValueChangedEventData>();
            this.eventActionsQueue.Enqueue(() => this.ValueChanged?.Invoke(eventDto.Key, eventDto.Value));
            break;
        }

        case "ValueRemoved": {
            ValueRemovedEventData eventDto = e.DecodeEventDto <ValueRemovedEventData>();
            this.eventActionsQueue.Enqueue(() => this.ValueRemoved?.Invoke(eventDto.Key));
            break;
        }

        default:
            throw new ArgumentOutOfRangeException($"Unknown event {e.EventName}");
        }
    }
Beispiel #5
0
        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;
            }
            }
        }
 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}");
         }
     }
 }
Beispiel #7
0
 void HandleEventHandler(object sender, EvmChainEventArgs e)
 {
 }