public void ConnectWithOldOAuthToken() { TestWrapper(async(GlimeshConnection connection) => { GlimeshConnection connection2 = await GlimeshConnection.ConnectViaOAuthToken(connection.GetOAuthTokenCopy()); GlimeshConnection connection3 = await GlimeshConnection.ConnectViaOAuthToken(connection2.GetOAuthTokenCopy()); }); }
public static GlimeshConnection GetGlimeshClient() { if (UnitTestBase.connection == null) { UnitTestBase.connection = GlimeshConnection.ConnectViaLocalhostOAuthBrowser(clientID, clientSecret, scopes).Result; } Assert.IsNotNull(UnitTestBase.connection); return(UnitTestBase.connection); }
protected static void TestWrapper(Func <GlimeshConnection, Task> function) { try { GlimeshConnection connection = UnitTestBase.GetGlimeshClient(); function(connection).Wait(); } catch (AggregateException aex) { Assert.Fail(aex.InnerException.ToString()); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
/// <summary> /// Creates an instance of the ChannelService. /// </summary> /// <param name="connection">The Glimesh connection to use</param> public ChannelService(GlimeshConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the OAuthService. /// </summary> /// <param name="connection">The Twitch connection to use</param> public OAuthService(GlimeshConnection connection) : base(connection, OAuthBaseAddress) { }
public static void Main(string[] args) { Task.Run(async() => { try { Logger.SetLogLevel(LogLevel.Debug); Logger.LogOccurred += Logger_LogOccurred; System.Console.WriteLine("Connecting to Glimesh..."); connection = await GlimeshConnection.ConnectViaLocalhostOAuthBrowser(clientID, clientSecret, scopes); if (connection != null) { System.Console.WriteLine("Glimesh connection successful!"); user = await connection.Users.GetCurrentUser(); if (user != null) { System.Console.WriteLine("Current User: "******"Channel ID: " + channel.id); client = await ChatEventClient.CreateWithToken(connection); client.OnChatMessageReceived += Client_OnChatMessageReceived; client.OnChannelUpdated += Client_OnChannelUpdated; client.OnFollowOccurred += Client_OnFollowOccurred; System.Console.WriteLine("Connecting client..."); if (await client.Connect()) { System.Console.WriteLine("Successfully connected!"); System.Console.WriteLine("Joining channel..."); if (await client.JoinChannelChat(channel.id) && await client.JoinChannelEvents(channel.id, user.id)) { System.Console.WriteLine("Successfully joined channel!"); await client.SendMessage(channel.id, "Hello World!"); while (true) { string line = System.Console.ReadLine(); await client.SendMessage(channel.id, line); } } } } } } } catch (Exception ex) { Logger.Log(ex); } }).Wait(); System.Console.ReadLine(); }
/// <summary> /// Creates a new instance of the ChatEventClient class. /// </summary> /// <param name="connection">The current connection</param> /// <param name="connectionUrl">The URL to connect with</param> private ChatEventClient(GlimeshConnection connection, string connectionUrl) { this.connectionUrl = connectionUrl; }
/// <summary> /// Creates a client using the user's acquired OAuth token. /// </summary> /// <returns>The chat client</returns> public static async Task <ChatEventClient> CreateWithClientID(GlimeshConnection connection) { OAuthTokenModel oauthToken = await connection.GetOAuthToken(); return(new ChatEventClient(connection, string.Format(CLIENT_ID_CONNECTION_URL, oauthToken.clientID))); }
/// <summary> /// Creates a client using the user's acquired OAuth token. /// </summary> /// <returns>The chat client</returns> public static async Task <ChatEventClient> CreateWithToken(GlimeshConnection connection) { OAuthTokenModel oauthToken = await connection.GetOAuthToken(); return(new ChatEventClient(connection, string.Format(TOKEN_CONNECTION_URL, oauthToken.accessToken))); }
/// <summary> /// Creates an instance of the ChatService. /// </summary> /// <param name="connection">The Glimesh connection to use</param> public UsersService(GlimeshConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the GlimeshServiceBase. /// </summary> /// <param name="connection">The Glimesh connection to use</param> /// <param name="baseAddress">The base address to use</param> public GlimeshServiceBase(GlimeshConnection connection, string baseAddress) { Validator.ValidateVariable(connection, "connection"); this.connection = connection; this.baseAddress = baseAddress; }
/// <summary> /// Creates an instance of the GlimeshServiceBase. /// </summary> /// <param name="connection">The Glimesh connection to use</param> public GlimeshServiceBase(GlimeshConnection connection) : this(connection, GlimeshRestAPIBaseAddressFormat) { }
public void GetAuthorizationCodeURLForOAuth() { string url = GlimeshConnection.GetAuthorizationCodeURLForOAuthBrowser(clientID, scopes, GlimeshConnection.DEFAULT_OAUTH_LOCALHOST_URL).Result; Assert.IsNotNull(url); }
/// <summary> /// Creates an instance of the CategoryService. /// </summary> /// <param name="connection">The Glimesh connection to use</param> public CategoryService(GlimeshConnection connection) : base(connection) { }