Ejemplo n.º 1
0
        private async Task Handle(StartMessage m)
        {
            if (_user != null)
            {
                throw new InvalidOperationException("Already started");
            }

            // create bot pattern

            _patternContext = new BotPattern.Context
            {
                UserId   = m.UserId,
                RoomName = m.RoomName,
                Service  = this
            };
            _pattern = (BotPattern)Activator.CreateInstance(m.PatternType, new object[] { _patternContext });

            // login by itself

            await LoginUser(m.UserId);

            if (_user == null)
            {
                throw new InvalidOperationException();
            }

            // enter room

            var roomInfo = await _user.EnterRoom(m.RoomName, CreateObserver <IRoomObserver>());

            _occupant = ((OccupantRef)roomInfo.Item1).WithRequestWaiter(this);

            // start bot

            await _pattern.OnStart();
        }
Ejemplo n.º 2
0
 public void SetOccupant(OccupantRef occupant)
 {
     _occupant = occupant;
 }