Exemplo n.º 1
0
        UdpSocket(UdpPlatform platform, UdpSerializerFactory serializerFactory, UdpConfig config)
        {
            this.platform          = platform;
            this.serializerFactory = serializerFactory;
            this.Config            = config.Duplicate();
            this.configCopy        = config;

            state          = UdpSocketState.Created;
            random         = new System.Random();
            stats          = new UdpStats();
            availableEvent = new AutoResetEvent(false);

            if (this.Config.NoiseFunction == null)
            {
                this.Config.NoiseFunction = delegate() { return((float)random.NextDouble()); };
            }

            readStream  = new UdpStream(new byte[config.PacketSize * 2]);
            writeStream = new UdpStream(new byte[config.PacketSize * 2]);
            streamPool  = new UdpStreamPool(this);

            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();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
 public static UdpSocket Create(UdpPlatform platform)
 {
     return(Create(platform, new UdpConfig()));
 }
Exemplo n.º 4
0
 public static UdpSocket Create(UdpPlatform platform, UdpConfig config)
 {
     return(Create(platform, () => new UdpStreamSerializer(), config));
 }
Exemplo n.º 5
0
 public static UdpSocket Create(UdpPlatform platform, UdpSerializerFactory serializer)
 {
     return(Create(platform, serializer, new UdpConfig()));
 }
Exemplo n.º 6
0
        /*
         #region Partial Methods
         * void DelayPacket (UdpEndPoint ep, byte[] data, int length);
         * void RecvDelayedPackets ();
         #endregion*/

        public static UdpSocket Create(UdpPlatform platform, UdpSerializerFactory serializer, UdpConfig config)
        {
            return(new UdpSocket(platform, serializer, config));
        }
Exemplo n.º 7
0
 public static void SetUdpPlatform(UdpPlatform platform)
 {
     UserAssignedPlatform = platform;
 }