public async Task <bool> UpdateSyntyAppearanceAsync(string userId, SyntyAppearance appearance) { userId = CleanupUserId(userId); var sessionId = HttpContext.GetSessionId(); if (sessionInfoProvider.TryGet(sessionId, out var si) && si.ActiveCharacterId != null) { return(playerManager.UpdateAppearance(si.ActiveCharacterId.Value, appearance)); } return(await UpdateSyntyAppearanceAsync(userId, "1", appearance)); }
public StreamerInfo GetStreamerInfo(string broadcasterId) { var streamer = gameData.GetUserByTwitchId(broadcasterId); var result = new StreamerInfo(); if (streamer != null) { result.StreamerUserId = broadcasterId; result.StreamerUserName = streamer.UserName; var gameSession = gameData.GetOwnedSessionByUserId(streamer.UserId); result.IsRavenfallRunning = gameSession != null; result.StreamerSessionId = gameSession?.Id; if (gameSession != null) { result.Started = gameSession.Started; var state = gameData.GetSessionState(gameSession.Id); if (state != null) { result.ClientVersion = state.ClientVersion; } var charactersInSession = gameData.GetSessionCharacters(gameSession); if (charactersInSession != null) { var session = this.HttpContext.GetSessionId(); if (sessionInfoProvider.TryGet(session, out var sessionInfo)) { var u = gameData.GetUser(sessionInfo.AccountId); if (u != null) { var c = charactersInSession.FirstOrDefault(x => x.UserId == u.Id); if (c != null) { result.JoinedCharacterId = c.Id; } } } result.PlayerCount = charactersInSession.Count; } } } return(result); }
public IExtensionConnection Get( System.Net.WebSockets.WebSocket socket, IReadOnlyDictionary <string, string> requestHeaders) { var sessionId = requestHeaders.GetSessionId(); if (!sessionInfoProvider.TryGet(sessionId, out var session)) { return(null); } if (socket == null) { return(null); } lock (mutex) { var connection = new ExtensionWebSocketConnection(logger, socket, packetDataSerializer, session, requestHeaders["broadcasterId"]); connections[sessionId] = connection; return(connection); } }
public async Task <string> GetTwitchUser() { if (sessionInfoProvider.TryGet(HttpContext.Session, out var session)) { return($"{{ \"login\": \"{session.UserName}\", \"id\": \"{session.UserId}\"}}"); } if (!this.sessionInfoProvider.TryGetTwitchToken(HttpContext.Session, out var key)) { return("nope"); } var twitch = new TwitchRequests(key, settings.TwitchClientId, settings.TwitchClientSecret); var twitchUser = await twitch.GetUserAsync(); await this.sessionInfoProvider.SetTwitchUserAsync(HttpContext.Session, twitchUser); return(twitchUser); }