Пример #1
0
        public ShippingCompany(string[] args)
        {
            myID = SetID("ShippingCompany", args);

            int nTraders;
            try
            {
                nTraders = Int32.Parse(args[1]);
            }
            catch (Exception)
            {
                throw new ApplicationException("Requires 2 command line arguments: first is id, second is number of traders");
            }

            DbConn dbConn = new DbConn();
            portDistances = DBUtil.GetPortDistancesLookup(dbConn);
            dbConn.Dispose();

            bankClient = new Client(ServerConfigs["Bank-Shipping"], AppSettings, myID, false);

            var conf = ServerConfigs["Trader-Shipping"];
            for (int i = 0; i != nTraders; ++i)
            {
                traderClients[conf.port] = new Client(conf, AppSettings, myID, false);
                moveWishes[conf.port] = new List<MoveContractMsg>();
                conf.port += 1;
            }
        }
Пример #2
0
        public Trader(string[] args)
        {
            myID = SetID("Trader", args);

            logic = new TraderLogic();

            var conf = ServerConfigs["Trader-Shipping"];
            conf.port = conf.port + (myID - 1);

            shippingServer = new Server(conf, AppSettings, false);
            bankClient = new Client(ServerConfigs["Bank-Trader"], AppSettings, myID, false);
            fateClient = new Client(ServerConfigs["FateAndGuesswork-Trader"], AppSettings, myID, true);
        }