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(); }
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(); }