Ejemplo n.º 1
0
        protected override async Task OnStart(bool restarted)
        {
            try
            {
                var observer = CreateObserver <IGameObserver>();
                var ret      = await _game.Join(_userId, _userName, observer, null);

                _gamePlayer = _game.Cast <GamePlayerRef>().WithRequestWaiter(this);
                _playerId   = ret.Item1;
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to join game({0})", e, _game.CastToIActorRef().Path);
                Self.Tell(InterfacedPoisonPill.Instance);
            }
        }
Ejemplo n.º 2
0
        async Task IUser.LeaveGame()
        {
            if (_enteredGame == null)
            {
                throw new InvalidOperationException();
            }

            // Let's exit from the room !

            await _enteredGame.Leave(_id);

            // Unbind an game actor from channel

            _channel.WithNoReply().UnbindActor(_enteredGame.CastToIActorRef());
            _enteredGame = null;
        }