Skip to content

Commit

Permalink
fix weird behaviors on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
Earu committed Oct 8, 2024
1 parent e07021e commit 9d5f085
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
Binary file added .DS_Store
Binary file not shown.
23 changes: 11 additions & 12 deletions Listeners/UnixLogListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ private void ProcessMessage(byte[] buffer)
{
using (BinaryReader reader = new(new MemoryStream(buffer, 0, buffer.Length)))
{
int type = reader.ReadInt32();
int level = reader.ReadInt32();

byte a = reader.ReadByte();
byte r = reader.ReadByte();
byte g = reader.ReadByte();
byte b = reader.ReadByte();

Color color = Color.FromArgb(a, r, g, b);
string group = ReadString(reader);
int type = reader.ReadInt32();
int level = reader.ReadInt32();
string group = ReadString(reader);
int r = reader.ReadByte();
int g = reader.ReadByte();
int b = reader.ReadByte();
int a = reader.ReadByte();

Color color = Color.FromArgb(a, r, g, b);
string fullMsg = ReadString(reader);

OnLog?.Invoke(this, new LogEventArgs(type, level, group, color, fullMsg));
Expand All @@ -59,7 +58,7 @@ private void ProcessMessage(byte[] buffer)

private async Task ProcessMessages()
{
byte[] eolSequence = Encoding.ASCII.GetBytes("<EOL>");
byte[] eolSequence = Encoding.ASCII.GetBytes("<EOL>\0");

int eolIndex = 0;
List<byte> dataBuffer = [];
Expand All @@ -70,7 +69,7 @@ private async Task ProcessMessages()
{
try
{
FileStream fs = new("/tmp/garrysmod_console", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
FileStream fs = new("/tmp/garrysmod_console", FileMode.Open, FileAccess.Read, FileShare.Read);
this.SetConnectionStatus(true);

while (true)
Expand Down
11 changes: 5 additions & 6 deletions Listeners/WindowsLogListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ private async Task ProcessMessages()
int type = reader.ReadInt32();
int level = reader.ReadInt32();
string group = ReadString(reader);
Color color = Color.FromArgb(
reader.ReadByte(),
reader.ReadByte(),
reader.ReadByte()
);
int r = reader.ReadByte();
int g = reader.ReadByte();
int b = reader.ReadByte();
int a = reader.ReadByte();

reader.ReadByte();
Color color = Color.FromArgb(a, r, g, b);

string fullMsg = ReadString(reader);
OnLog?.Invoke(this, new LogEventArgs(type, level, group, color, fullMsg));
Expand Down
Binary file modified Modules/gmsv_xconsole_osx64.dll
100644 → 100755
Binary file not shown.

0 comments on commit 9d5f085

Please sign in to comment.