void ProcessTimeouts()
        {
            if ((frame & 3) == 3)
            {
                uint now = GetCurrentTime();

                for (int i = 0; i < connList.Count; ++i)
                {
                    UdpConnection cn = connList[i];

                    switch (cn.state)
                    {
                    case UdpConnectionState.Connecting:
                        cn.ProcessConnectingTimeouts(now);
                        break;

                    case UdpConnectionState.Connected:
                        cn.ProcessConnectedTimeouts(now);
                        break;

                    case UdpConnectionState.Disconnected:
                        cn.ChangeState(UdpConnectionState.Destroy);
                        break;

                    case UdpConnectionState.Destroy:
                        if (DestroyConnection(cn))
                        {
                            --i;
                        }
                        break;
                    }
                }
            }
        }
        void OnEventClose(UdpEvent ev)
        {
            if (ChangeState(UdpSocketState.Running, UdpSocketState.Shutdown))
            {
                for (int i = 0; i < connList.Count; ++i)
                {
                    UdpConnection cn = connList[i];
                    cn.SendCommand(UdpCommandType.Disconnected);
                    cn.ChangeState(UdpConnectionState.Disconnected);
                }

                if (platform.Close() == false)
                {
                    UdpLog.Error("failed to shutdown socket interface, platform code: {0}", platform.PlatformError.ToString());
                }

                connList.Clear();
                connLookup.Clear();
                eventQueueIn.Clear();
                pendingConnections.Clear();

                GetReadStream().Data      = null;
                GetWriteStream(0, 0).Data = null;
                UdpLog.Error("OnEventClose: {0}", ev.EndPoint.ToString());
            }
        }
        void AcceptConnection(UdpEndPoint ep)
        {
            UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server);

            cn.ChangeState(UdpConnectionState.Connected);
        }
Beispiel #4
0
        void AcceptConnection(UdpEndPoint ep, object replyObj)
        {
            UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server, replyObj);

            cn.ChangeState(UdpConnectionState.Connected);
        }