Skip to content

Commit 6597261

Browse files
committed
Change readBufferSize to use enums
1 parent 90f4cd6 commit 6597261

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

Unity-Twitch-Chat/Assets/ExampleProject/Scenes/ExampleScene.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ MonoBehaviour:
773773
showThreadDebug: 1
774774
useRandomColorForUndefined: 1
775775
readInterval: 50
776-
readBufferSize: 1024
776+
readBufferSize: 256
777777
writeInterval: 50
778778
--- !u!4 &1312367230
779779
Transform:

Unity-Twitch-Chat/Assets/Package/Runtime/IRC.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public partial class IRC : MonoBehaviour
4848

4949
[Tooltip("The number of milliseconds between each time the read thread checks for new messages.")]
5050
[SerializeField] public int readInterval = 50;
51-
[Tooltip("The capacity of the read buffer. Smaller values consume less memory but require more cycles to retrieve data.")]
52-
[SerializeField] public int readBufferSize = 1024;
51+
[Tooltip("The capacity of the read buffer. Smaller values consume less memory but require more cycles to retrieve data (CPU usage)")]
52+
[SerializeField] public ReadBufferSize readBufferSize = ReadBufferSize._256;
5353

5454
[Header("Chat write settings (write thread)")]
5555

5656
[Tooltip("The number of milliseconds between each time the write thread checks its queues.")]
5757
public int writeInterval = 50;
5858

59-
59+
6060
// If the game is paused for a significant amount of time and then unpaused,
6161
// there could be a lot of data to handle, which could cause lag spikes.
6262
// To prevent this, we limit the amount of data handled per frame.
@@ -301,7 +301,7 @@ public void SendChatMessage(string message)
301301
/// Join a new channel
302302
/// </summary>
303303
/// <param name="channel">The channel to join</param>
304-
public void JoinChannel(string channel)
304+
public void JoinChannel(string channel)
305305
{
306306
if (channel != "")
307307
connection.SendCommand("JOIN #" + channel.ToLower(), true);
@@ -311,7 +311,7 @@ public void JoinChannel(string channel)
311311
/// Leaves a channel
312312
/// </summary>
313313
/// <param name="channel">The channel to leave</param>
314-
public void LeaveChannel(string channel)
314+
public void LeaveChannel(string channel)
315315
{
316316
if (channel != "")
317317
connection.SendCommand("PART #" + channel.ToLower(), true);

Unity-Twitch-Chat/Assets/Package/Runtime/TwitchConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public TwitchConnection(IRC irc)
2323
this.nick = irc.username;
2424
this.channel = irc.channel;
2525

26-
this.readBufferSize = irc.readBufferSize;
26+
this.readBufferSize = (int)irc.readBufferSize; // Parse enum value
2727
this.readInterval = irc.readInterval;
2828
this.writeInterval = irc.writeInterval;
2929

Unity-Twitch-Chat/Assets/Package/Runtime/Utils.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ public enum IRCReply
2424
NO_CONNECTION = 499,
2525
}
2626

27+
28+
public enum ReadBufferSize
29+
{
30+
_32 = 32,
31+
_64 = 64,
32+
_128 = 128,
33+
_256 = 256,
34+
_512 = 512,
35+
_1024 = 1024,
36+
_2048 = 2048,
37+
_4096 = 4096,
38+
}
39+
2740
public static class Tags
2841
{
2942
public static string read = "<color=#00ff00><b>[IRC READ]</b></color>";

0 commit comments

Comments
 (0)