Exemplo n.º 1
0
        private void NetWrite()
        {
            WaitHandle[] wait = new WaitHandle[] {
                exitEvent,
                m_MsgQueue
            };

            bool bCont = true;

            while (bCont)
            {
                int res = WaitHandle.WaitAny(wait);
                switch (res)
                {
                case 0:
                    bCont = false;

                    for (int i = 0; i < NetworkConnectivity.m_Channels.Count; i++)
                    {
                        NetworkChannel ch = (NetworkChannel)NetworkConnectivity.m_Channels[i];
                        if (ch != null)
                        {
                            ch.Disconnect();
                        }
                    }
                    NetworkConnectivity.m_Channels.Clear();
                    break;

                case 1:
                    NetQueuedMessage ntcpm = m_MsgQueue.Dequeue(100) as NetQueuedMessage;
                    if (ntcpm != null && ntcpm.m_Socket != null)
                    {
                        rWrite(ntcpm.m_Channel, ntcpm.m_Socket, ntcpm.Data);
                    }
                    break;
                }
            }

            exitEvent.Reset();
        }
Exemplo n.º 2
0
 internal NetQueuedMessage(NetworkChannel channel, Socket socket, byte[] data)
 {
     m_Socket  = socket;
     m_Channel = channel;
     Data      = data;
 }
Exemplo n.º 3
0
 internal void Write(NetworkChannel channel, Socket socket, byte[] data)
 {
     m_MsgQueue.Enqueue(new NetQueuedMessage(channel, socket, data));
 }