/// <summary> /// Creates an instance of the TrovoServiceBase. /// </summary> /// <param name="connection">The Trovo connection to use</param> /// <param name="baseAddress">The base address to use</param> public TrovoServiceBase(TrovoConnection connection, string baseAddress) { Validator.ValidateVariable(connection, "connection"); this.connection = connection; this.baseAddress = baseAddress; this.clientID = connection.ClientID; }
public static void Main(string[] args) { Task.Run(async() => { try { Logger.SetLogLevel(LogLevel.Debug); Logger.LogOccurred += Logger_LogOccurred; System.Console.WriteLine("Connecting to Trovo..."); connection = await TrovoConnection.ConnectViaLocalhostOAuthBrowser(clientID, scopes); if (connection != null) { System.Console.WriteLine("Trovo connection successful!"); PrivateUserModel user = await connection.Users.GetCurrentUser(); if (user != null) { System.Console.WriteLine("Current User: "******"Channel Title: " + channel.live_title); chat = new ChatClient(connection); chat.OnChatMessageReceived += Chat_OnChatMessageReceived; System.Console.WriteLine("Connecting to chat..."); if (await chat.Connect(await connection.Chat.GetToken())) { System.Console.WriteLine("Successfully connected to chat!"); await chat.SendMessage("Hello World!"); ChatViewersModel viewers = await connection.Chat.GetViewers(channel.channel_id, 1000); while (true) { string line = System.Console.ReadLine(); await chat.SendMessage(line); } } } } } } catch (Exception ex) { Logger.Log(ex); } }).Wait(); System.Console.ReadLine(); }
public static TrovoConnection GetTrovoClient() { if (UnitTestBase.connection == null) { UnitTestBase.connection = TrovoConnection.ConnectViaLocalhostOAuthBrowser(clientID, scopes).Result; } Assert.IsNotNull(UnitTestBase.connection); return(UnitTestBase.connection); }
protected static void TestWrapper(Func <TrovoConnection, Task> function) { try { TrovoConnection connection = UnitTestBase.GetTrovoClient(); function(connection).Wait(); } catch (AggregateException aex) { Assert.Fail(aex.InnerException.ToString()); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }
/// <summary> /// Creates an instance of the UsersService. /// </summary> /// <param name="connection">The Trovo connection to use</param> public UsersService(TrovoConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the ChatService. /// </summary> /// <param name="connection">The Trovo connection to use</param> public ChatService(TrovoConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the CategoryService. /// </summary> /// <param name="connection">The Trovo connection to use</param> public CategoryService(TrovoConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the ChatClient. /// </summary> /// <param name="connection">The Trovo connection to use</param> public ChatClient(TrovoConnection connection) { this.connection = connection; }
/// <summary> /// Creates an instance of the OAuthService. /// </summary> /// <param name="connection">The YouTube connection to use</param> public OAuthService(TrovoConnection connection) : base(connection) { }
/// <summary> /// Creates an instance of the TrovoServiceBase. /// </summary> /// <param name="connection">The YouTube connection to use</param> public TrovoServiceBase(TrovoConnection connection) : this(connection, TrovoRestAPIBaseAddressFormat) { }