/// <summary>
        /// Opens a connection to the server and start receiving messages.
        /// </summary>
        /// <param name="oauth">Your password should be an OAuth token authorized through our API with the chat:read scope (to read messages) and the  chat:edit scope (to send messages)</param>
        /// <param name="nick">Your nickname must be your Twitch username (login name) in lowercase</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ConnectAsync(string oauth, string nickId, CancellationToken cancellationToken)
        {
            _twitchMessageClient = new WebSocketPubSubClient();
            _twitchMessageClient.MessageReceived  += OnRawMessageReceived;
            _twitchMessageClient.ConnectionClosed += OnConnectionClosed;

            return(_twitchMessageClient.ConnectAsync(oauth, nickId.ToLower(), cancellationToken));
        }
        /// <summary>
        /// Opens a connection to the server and start receiving messages.
        /// </summary>
        /// <param name="oauth">Your password should be an OAuth token authorized through our API with the chat:read scope (to read messages) and the  chat:edit scope (to send messages)</param>
        /// <param name="nick">Your nickname must be your Twitch username (login name) in lowercase</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ConnectAsync(string oauth, string nick, CancellationToken cancellationToken)
        {
            if (!oauth.StartsWith("oauth:"))
            {
                throw new ArgumentException("OAuth parameter must in format 'oauth:xxxx'");
            }

            _twitchMessageClient = new WebSocketMessageClient();
            _twitchMessageClient.MessageReceived  += OnRawMessageReceived;
            _twitchMessageClient.ConnectionClosed += OnConnectionClosed;

            return(_twitchMessageClient.ConnectAsync(oauth, nick.ToLower(), cancellationToken));
        }
Esempio n. 3
0
 /// <summary>
 /// Attempts to Reconnect asynchronously.
 /// </summary>
 /// <returns></returns>
 public Task ReConnectAsync()
 {
     return(_twitchMessageClient.ConnectAsync(controller._secrets.api_token, controller._secrets.nick_id, controller.cts2));
 }
Esempio n. 4
0
 /// <summary>
 /// Attempts to Reconnect asynchronously.
 /// </summary>
 /// <returns></returns>
 public Task ReConnectAsync()
 {
     return(_twitchMessageClient.ConnectAsync("oauth:" + controller._secrets.api_token, controller._secrets.username, controller.cts));
 }