/** * This methods cleanups the the running thread for the receiving socket */ private void CleanUp() { BotLogger.LogDebug("Cleaning up the bot!"); try { ReceivingThread.Interrupt(); if (!ReceivingThread.Join(1000)) { ReceivingThread.Abort(); } } catch (Exception e) { if (e is ThreadAbortException tabex) { BotLogger.LogDebug("Couldn't terminate the thread in time. Forced it's shutdown."); } else { if (e is ThreadInterruptedException tiex) { BotLogger.LogDebug("Interrupted the exception!"); } } } BotLogger.LogDebug("Thread terminated!"); }
private void RequestTwitchMembershipStateEvents() { BotLogger.LogDebug("Requesting Membership capabilities."); string data = "CAP REQ :twitch.tv/membership twitch.tv/commands twitch.tv/tags"; Socket.Send(data); }
private void initTimer() { Timer_memory = new Timer((e) => { long bytes = GC.GetTotalMemory(false); double megabytes = Math.Round(bytes * 1E-6, 3); BotLogger.LogDebug($"Memory usage is : {megabytes}MB"); }, null, 1000, 60 * 1000); }
public void Connect(string oauth) { BotLogger.LogDebug("[ >>Connecting! ]"); Socket.Connect(); SendOauth(oauth); SendToIRC(IRCSymbols.FormatUsername(Username)); SendToIRC(IRCSymbols.FormatJoin(DefaultChannel)); RequestTwitchMembershipStateEvents(); this.Running = true; ReceivingThread.Start(); }
private void ReceiveData() { while (Running) { string data = null; data = Socket.Receive(); if (data != null) { /* Parse * decide what to do with data */ BotLogger.LogDebug(data); CallbackHandler.RunCallbacks(data); } } }
private void SendOauth(string oauth) { BotLogger.LogDebug("[ >> Sending OAUTH ]"); Socket.Send(IRCSymbols.FormatOAuth(oauth)); }
private void sendPONG() { BotLogger.LogDebug("[ >> Sending PONG ]"); SendToIRC("PONG :tmi.twitch.tv"); }
public void Debug() { BotLogger.LogDebug("[ >>Sending HelloWorld! ]"); SendToIRC(IRCSymbols.FormatChannelMessage(DefaultChannel, "HelloWorld!")); initTimer(); }