示例#1
0
 /**
  *  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!");
 }
示例#2
0
        private void RequestTwitchMembershipStateEvents()
        {
            BotLogger.LogDebug("Requesting Membership capabilities.");
            string data = "CAP REQ :twitch.tv/membership twitch.tv/commands twitch.tv/tags";

            Socket.Send(data);
        }
示例#3
0
 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);
 }
示例#4
0
 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();
 }
示例#5
0
 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);
         }
     }
 }
示例#6
0
 private void SendOauth(string oauth)
 {
     BotLogger.LogDebug("[ >> Sending OAUTH ]");
     Socket.Send(IRCSymbols.FormatOAuth(oauth));
 }
示例#7
0
 private void sendPONG()
 {
     BotLogger.LogDebug("[ >> Sending PONG ]");
     SendToIRC("PONG :tmi.twitch.tv");
 }
示例#8
0
 public void Debug()
 {
     BotLogger.LogDebug("[ >>Sending HelloWorld! ]");
     SendToIRC(IRCSymbols.FormatChannelMessage(DefaultChannel, "HelloWorld!"));
     initTimer();
 }