Beispiel #1
0
        static void Main(string[] args)
        {
            WorldGenerator generator = new WorldGenerator();
            var            World     = generator.GenerateWorldTerrain();

            generator.Populate(World);
            WorldResolver resolver = new WorldResolver();

            RabbitWrapper wrapper = new RabbitWrapper();

            wrapper.Connect();

            JsonConverter jsonwriter = new JsonConverter();

            var task = new Task(() => WSServer.Setup(null));

            task.RunSynchronously();

            resolver.World = World;
            while (true)
            {
                resolver.Resolve();
                //Console.WriteLine(World.Agents.Count);
                //wrapper.WriteAll(jsonwriter.WriteToJson(World.Agents));
                //wrapper.WriteAll(jsonwriter.WriteToJson(World.Terrain), "terrain_queue");
                Thread.Sleep(1000);
            }
        }
        public ITransportListener StartConnectionListener(string uri, int port)
        {
            ServerConfig config = new ServerConfig();
            config.Port = port;
            config.MaxRequestLength = 100000;

            string host = uri;
            if (host != "Any")
            {
                IPAddress[] ipAddresses = Dns.GetHostAddresses(host);
                if (ipAddresses.Length == 0)
                    throw new Error(ErrorCode.CONNECTION_ERROR, "Cannot identify IP address by hostname.");
                config.Ip = ipAddresses[0].ToString();  // we take first entry as it does not matter which one is used
            }
            else
            {
                config.Ip = "Any";
            }
            var server = new WSServer();
            server.Setup(config);
            server.Start();
            return server as ITransportListener;
        }