Skip to content

Commit

Permalink
Merge pull request #444 from JasonXuDeveloper/development
Browse files Browse the repository at this point in the history
fixed nino.serialization bug + fixed ws bug
  • Loading branch information
JasonXuDeveloper authored Dec 3, 2022
2 parents 3fb469b + 0922b4b commit 2ddcac5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public bool IsConnected
private volatile bool thPinging;
private volatile bool thPong;
private volatile bool wsConnected;
private volatile bool inGame;

private Thread socketThread;
private Thread pingThread;
Expand Down Expand Up @@ -225,6 +226,11 @@ public void OnDestroy()
}
}

private void OnApplicationPause(bool pauseStatus)
{
inGame = !pauseStatus;
}

public void OnApplicationQuit()
{
Close();
Expand Down Expand Up @@ -419,7 +425,7 @@ private async void RunSocketThread(object obj)
WebSocket webSocket = (WebSocket) obj;
while (connected)
{
if (webSocket.IsConnected)
if (webSocket.IsConnected || !inGame)
{
await TimeMgr.Delay(config.reconnectDelay);
}
Expand Down
15 changes: 13 additions & 2 deletions UnityProject/Assets/Dependencies/Nino/Serialization/Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,19 @@ public void DecompressAndReadNumber<T>(ref T result) where T : unmanaged
Unsafe.As<T, byte>(ref result) = ReadByte();
return;
case CompressType.SByte:
Unsafe.As<T, sbyte>(ref result) = ReadSByte();
return;
switch (result)
{
case int _:
var temp = (int)ReadSByte();
Unsafe.As<T, int>(ref result) = temp;
return;
case long _:
var temp2 = (long)ReadSByte();
Unsafe.As<T, long>(ref result) = temp2;
return;
default:
throw new InvalidOperationException("invalid compress type");
}
case CompressType.Int16:
Unsafe.As<T, short>(ref result) = ReadInt16();
return;
Expand Down

0 comments on commit 2ddcac5

Please sign in to comment.