示例#1
0
        public override async Task OnActivateAsync()
        {
            await InitializeState();

            var provider = GetStreamProvider(StreamConstants.ProviderName);
            var stream   = provider.GetServerStream(TopicIds.Player(State.UserId, State.RoomId));

            _player       = new Player(State);
            _subscription = await this.EnsureIsSubscribedOnce(stream);

            await base.OnActivateAsync();
        }
示例#2
0
        public async Task <IPlayer> JoinRoom(string roomId, Guid connectionId)
        {
            var userId     = this.GetPrimaryKey();
            var connection = GrainFactory.GetGrain <IConnectionGrain>(connectionId);
            var topicId    = TopicIds.Player(userId, roomId);
            var player     = GrainFactory.GetGrain <IPlayerGrain>(userId, roomId, null);
            await player.Ping();

            await connection.Connect(topicId);

            return(player);
        }