bool CheckState(udpSocketState s) { if (state != s) { return(false); } return(true); }
bool ChangeState(udpSocketState from, udpSocketState to) { if (CheckState(from)) { state = to; return(true); } return(false); }
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(); }