Exemple #1
0
        bool CheckState(udpSocketState s)
        {
            if (state != s)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        bool ChangeState(udpSocketState from, udpSocketState to)
        {
            if (CheckState(from))
            {
                state = to;
                return(true);
            }

            return(false);
        }
Exemple #3
0
        UdpSocket(UdpPlatform platform, UdpSerializerFactory serializerFactory, UdpConfig config)
        {
            this.platform          = platform;
            this.serializerFactory = serializerFactory;
            this.Config            = config.Duplicate();

            random        = new Random(500);
            state         = udpSocketState.Created;
            receiveBuffer = new byte[config.MtuMax * 2];
            objectBuffer  = new byte[config.MtuMax * 2];

            eventQueueIn  = new Queue <UdpEvent>(config.InitialEventQueueSize);
            eventQueueOut = new Queue <UdpEvent>(config.InitialEventQueueSize);

            threadSocket              = new Thread(NetworkLoop);
            threadSocket.Name         = "udpkit thread";
            threadSocket.IsBackground = true;
            threadSocket.Start();
        }