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 void GetCurrentUser() { TestWrapper(async(TrovoConnection connection) => { PrivateUserModel user = await connection.Users.GetCurrentUser(); Assert.IsNotNull(user); Assert.IsTrue(!string.IsNullOrEmpty(user.userId)); Assert.IsTrue(!string.IsNullOrEmpty(user.userName)); }); }