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(); }
public static UdpSocket Create(UdpPlatform platform) { return(Create(platform, new UdpConfig())); }
public static UdpSocket Create(UdpPlatform platform, UdpConfig config) { return(Create(platform, () => new UdpStreamSerializer(), config)); }
public static UdpSocket Create(UdpPlatform platform, UdpSerializerFactory serializer) { return(Create(platform, serializer, new UdpConfig())); }
/* #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)); }
public static void SetUdpPlatform(UdpPlatform platform) { UserAssignedPlatform = platform; }