From a57a0d711e39be3216df270a9e5e61029e3bd7e6 Mon Sep 17 00:00:00 2001 From: Nicholas Ewalt Date: Thu, 23 Jun 2016 07:22:29 -0700 Subject: [PATCH] I have no words... I can't believe I missed the one file I was trying to upload.. --- Assets/HOTK/Twitch/TwitchIRC.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/HOTK/Twitch/TwitchIRC.cs b/Assets/HOTK/Twitch/TwitchIRC.cs index 4bf0267..b338d8d 100644 --- a/Assets/HOTK/Twitch/TwitchIRC.cs +++ b/Assets/HOTK/Twitch/TwitchIRC.cs @@ -2,6 +2,7 @@ using UnityEngine; using System.Collections; using System.Collections.Generic; +using System.Threading; public class TwitchIRC : MonoBehaviour { @@ -52,7 +53,10 @@ private void IRCInputProcedure(System.IO.TextReader input, System.Net.Sockets.Ne while (!_stopThreads) { if (!networkStream.DataAvailable) + { + Thread.Sleep(20); continue; + } _buffer = input.ReadLine(); @@ -86,10 +90,18 @@ private void IRCOutputProcedure(System.IO.TextWriter output) { lock (_commandQueue) { - if (_commandQueue.Count <= 0) continue; + if (_commandQueue.Count <= 0) + { + Thread.Sleep(20); + continue; + } // https://github.com/justintv/Twitch-API/blob/master/IRC.md#command--message-limit //have enough time passed since we last sent a message/command? - if (stopWatch.ElapsedMilliseconds <= 1750) continue; + if (stopWatch.ElapsedMilliseconds <= 1750) + { + Thread.Sleep(20); + continue; + } //send msg. output.WriteLine(_commandQueue.Peek()); output.Flush();