public static void OnLoggedOut() { loggedIn = false; loginSession = null; currentUserId = null; socketConnected = false; Users.Clear(); ReadStates.Clear(); Messages.Clear(); Channels.Clear(); Members.Clear(); Groups.Clear(); HasMoreMembers.Clear(); DiscoverChannels.Clear(); if (_instance != null) { using (_instance.window.getScope()) { HomePage.currentState.Clear(); } } _client.Close(); UpdateWindowCanvas(); }
public static void OnLoggedIn() { try { UnityOAuth.GetAuthorizationCodeAsync("marketplace", response => { if (response.AuthCode != null) { Promise.All( Utils .Get <EditorSessionTokenResponse>($"/auth/editor?code={response.AuthCode}") .Then(sessionTokenResponse => { loginSession = sessionTokenResponse.loginSessionToken; currentUserId = sessionTokenResponse.userId; loggedIn = true; Utils.Get <DiscoverChannelsResponse>( "/api/connectapp/channels?discover=true" ).Then(discoverResponse => { foreach (var key in discoverResponse.channelMap.Keys) { if (!discoverResponse.channelMap[key].groupId.IsNullOrEmpty()) { discoverResponse.channelMap[key].topic = discoverResponse .groupFullMap[discoverResponse.channelMap[key].groupId].description; } } DiscoverChannels.AddRange( discoverResponse.discoverList .Select(channelId => discoverResponse.channelMap[channelId]) ); UpdateWindowCanvas(); }); UpdateWindowCanvas(); }), InitializeWebSocket() ).Then(SendConnectFrame); } }); } catch (Exception exception) { if (exception.Message != "User is not logged in or user status invalid.") { OnLoggedIn(); } } }