/// <summary> /// Initializes the TwitchChatClient class. /// </summary> /// <param name="channel">The channel to connect to.</param> /// <param name="credentials">The credentials to use to log in.</param> /// <param name="chatCommandIdentifier">The identifier to be used for reading and writing commands from chat.</param> /// <param name="whisperCommandIdentifier">The identifier to be used for reading and writing commands from whispers.</param> /// <param name="logging">Whether or not logging to console should be enabled.</param> /// <param name="autoReListenOnExceptions">By default, TwitchClient will silence exceptions and auto-relisten for overall stability. For debugging, you may wish to have the exception bubble up, set this to false.</param> public TwitchClient(ConnectionCredentials credentials, string channel = null, char chatCommandIdentifier = '!', char whisperCommandIdentifier = '!', bool logging = false, bool autoReListenOnExceptions = true) { log($"TwitchLib-TwitchClient initialized, assembly version: {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"); _credentials = credentials; TwitchUsername = _credentials.TwitchUsername; _autoJoinChannel = channel?.ToLower(); if (chatCommandIdentifier != '\0') { _chatCommandIdentifiers.Add(chatCommandIdentifier); } if (whisperCommandIdentifier != '\0') { _whisperCommandIdentifiers.Add(whisperCommandIdentifier); } Logging = logging; AutoReListenOnException = autoReListenOnExceptions; _client = new WebSocket($"ws://{_credentials.TwitchHost}:{_credentials.TwitchPort}"); _client.OnOpen += _client_OnConnected; _client.OnMessage += _client_OnMessage; _client.OnClose += _client_OnDisconnected; _client.OnError += _client_OnError; }