Cleaned Listener.cs a bit
Ok I know what I did made no sense except to make the code cleaner and to avoid throwing an array of size 0 to the MessagePumper. This part of the core is very important & used every time there's incoming data, that's the main reason I wanted to clean it up.
In Listener.cs add the following function:
That's a function to check if we have any connection waiting in the m_Accepted queue.
Now modify the Socket[] Slice() function by removing the following lines:
Those lines are no longer necessary.
Now open MessagePump.cs
and change the CheckListener() function to this:
That's it. Thanks.
Ok I know what I did made no sense except to make the code cleaner and to avoid throwing an array of size 0 to the MessagePumper. This part of the core is very important & used every time there's incoming data, that's the main reason I wanted to clean it up.
In Listener.cs add the following function:
Code:
public bool bSocketWaiting()
{
if (m_Accepted.Count > 0)
return true;
else
return false;
}
That's a function to check if we have any connection waiting in the m_Accepted queue.
Now modify the Socket[] Slice() function by removing the following lines:
Code:
if ( m_Accepted.Count == 0 )
return m_EmptySockets;
Now open MessagePump.cs
and change the CheckListener() function to this:
Code:
private void CheckListener()
{
for ( int j = 0; j < m_Listeners.Length; ++j )
{
if (m_Listeners[j].bSocketWaiting())
{
Socket[] accepted = m_Listeners[j].Slice();
for ( int i = 0; i < accepted.Length; ++i )
{
NetState ns = new NetState( accepted[i], this );
ns.Start();
if ( ns.Running )
Console.WriteLine( "Client: {0}: Connected. [{1} Online]", ns, } NetState.Instances.Count );
}
}
}
That's it. Thanks.