Skip to content

Commit

Permalink
I have no words...
Browse files Browse the repository at this point in the history
I can't believe I missed the one file I was trying to upload..
  • Loading branch information
Hotrian committed Jun 23, 2016
1 parent 019f5f4 commit a57a0d7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Assets/HOTK/Twitch/TwitchIRC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Threading;

public class TwitchIRC : MonoBehaviour
{
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a57a0d7

Please sign in to comment.