I'm invoking NetManager's PollEvents method from Unity's Update loop.
I sometimes will receive packets that require some time to be processed, namely scene-loading packets.
These scene-loading packets should pause all other packets from being polled until the scenes they are referencing are loaded.
I modified the NetManager.cs file to achieve this as such:
public bool Pause;
public void PollEvents()
{
if (Pause) return;
if (UnsyncedEvents)
return;
int eventsCount;
lock (_netEventsQueue)
eventsCount = _netEventsQueue.Count;
for(int i = 0; i < eventsCount; i++)
{
NetEvent evt;
lock (_netEventsQueue)
evt = _netEventsQueue.Dequeue();
ProcessEvent(evt);
if (Pause) return;
}
}
It works so far, but I'm wondering if this would break something else down the pipe (keep-alive packets, acks, ... etc).
And if it does, would it be possible to add this feature?
After some thinking, I decided that queuing up received messages and processing them on my terms would be safer than messing with the library internals.
My scenario is as follows:
I modified the NetManager.cs file to achieve this as such:
It works so far, but I'm wondering if this would break something else down the pipe (keep-alive packets, acks, ... etc). And if it does, would it be possible to add this feature?
Library version: [release version (0.9.5.2)]
Framework: [Unity]
OS: [Windows]