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(); }
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); }