コード例 #1
0
        public void ConnectWithOldOAuthToken()
        {
            TestWrapper(async(GlimeshConnection connection) =>
            {
                GlimeshConnection connection2 = await GlimeshConnection.ConnectViaOAuthToken(connection.GetOAuthTokenCopy());

                GlimeshConnection connection3 = await GlimeshConnection.ConnectViaOAuthToken(connection2.GetOAuthTokenCopy());
            });
        }
コード例 #2
0
        public static GlimeshConnection GetGlimeshClient()
        {
            if (UnitTestBase.connection == null)
            {
                UnitTestBase.connection = GlimeshConnection.ConnectViaLocalhostOAuthBrowser(clientID, clientSecret, scopes).Result;
            }

            Assert.IsNotNull(UnitTestBase.connection);
            return(UnitTestBase.connection);
        }
コード例 #3
0
 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());
     }
 }
コード例 #4
0
 /// <summary>
 /// Creates an instance of the ChannelService.
 /// </summary>
 /// <param name="connection">The Glimesh connection to use</param>
 public ChannelService(GlimeshConnection connection) : base(connection)
 {
 }
コード例 #5
0
 /// <summary>
 /// Creates an instance of the OAuthService.
 /// </summary>
 /// <param name="connection">The Twitch connection to use</param>
 public OAuthService(GlimeshConnection connection) : base(connection, OAuthBaseAddress)
 {
 }
コード例 #6
0
        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();
        }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
        /// <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)));
        }
コード例 #9
0
        /// <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)));
        }
コード例 #10
0
 /// <summary>
 /// Creates an instance of the ChatService.
 /// </summary>
 /// <param name="connection">The Glimesh connection to use</param>
 public UsersService(GlimeshConnection connection) : base(connection)
 {
 }
コード例 #11
0
 /// <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;
 }
コード例 #12
0
 /// <summary>
 /// Creates an instance of the GlimeshServiceBase.
 /// </summary>
 /// <param name="connection">The Glimesh connection to use</param>
 public GlimeshServiceBase(GlimeshConnection connection) : this(connection, GlimeshRestAPIBaseAddressFormat)
 {
 }
コード例 #13
0
        public void GetAuthorizationCodeURLForOAuth()
        {
            string url = GlimeshConnection.GetAuthorizationCodeURLForOAuthBrowser(clientID, scopes, GlimeshConnection.DEFAULT_OAUTH_LOCALHOST_URL).Result;

            Assert.IsNotNull(url);
        }
コード例 #14
0
 /// <summary>
 /// Creates an instance of the CategoryService.
 /// </summary>
 /// <param name="connection">The Glimesh connection to use</param>
 public CategoryService(GlimeshConnection connection) : base(connection)
 {
 }