Esempio n. 1
0
        private static void Main(string[] args)
        {
            Log.Debug($"{nameof(Main)} (enter)");

            SignatureService.LoadPublicKey("Team1/StockServer");

            ConversationManager.Start(ConversationBuilder);
            ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, Config.GetInt(Config.BROKER_PORT));

            RequestStockStream();
            PrintMenu();
            PortfolioManager.LoadPortfolios();

            var input = Console.ReadLine();

            while (!input.Equals("exit"))
            {
                RequestStockStream();
                PrintMenu();
                input = Console.ReadLine();
            }

            ConversationManager.Stop();

            Log.Debug($"{nameof(Main)} (exit)");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Log.Debug($"{nameof(Main)} (enter)");

            SignatureService.LoadPrivateKey("Team1/StockServer");

            StockData.Init();
            ConversationManager.Start(ConversationBuilder);

            ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, Config.GetInt(Config.STOCK_SERVER_PORT));
            ComService.AddTcpListener(Config.DEFAULT_TCP_CLIENT, Config.GetInt(Config.STOCK_SERVER_TCP_PORT));

            Log.Info("Starting simulation.");
            Task.Run(() => RunSimulation());

            Log.Info("Waiting for StockStreamRequestMessages.");
            Log.Info("Pres any key to close program.");
            Console.ReadKey();

            lock (RunSimLock)
            {
                IsSimRunning = false;
            }

            Log.Debug($"{nameof(Main)} (exit)");
        }
Esempio n. 3
0
        public void AccessClientTest()
        {
            var a1_localPort = 231;
            var a1_id        = "a1Id";

            var a2_localPort = 241;
            var a2_id        = "a2Id";

            var a3_localPort = 261;
            var a3_id        = "a3Id";



            ComService.AddUdpClient(a1_id, a1_localPort);
            ComService.AddUdpClient(a2_id, a2_localPort);
            ComService.AddUdpClient(a3_id, a3_localPort);

            var pb = ComService.GetClient(a2_id);

            Assert.AreEqual(a2_localPort, pb.getConnectedPort());

            ComService.RemoveClient(a1_id);
            ComService.RemoveClient(a2_id);
            ComService.RemoveClient(a3_id);
        }
Esempio n. 4
0
        public Login()
        {
            InitializeComponent();
            ConversationManager.Start(ConversationBuilder.Builder);

            ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, 0);

            TraderModel.Current = new TraderModel();
        }
Esempio n. 5
0
        public void AddClientTest()
        {
            var a1_localPort = 354;
            var a1_id        = "a1Id";

            Assert.IsFalse(ComService.HasClient());
            ComService.AddUdpClient(a1_id, a1_localPort);
            Assert.IsTrue(ComService.HasClient());
            ComService.RemoveClient(a1_id);
        }
Esempio n. 6
0
        public void RemoveClientTest()
        {
            var a1_localPort = 231;
            var a1_id        = "a1Id";

            var a2_localPort = 241;
            var a2_id        = "a2Id";

            ComService.AddUdpClient(a1_id, a1_localPort);
            ComService.AddUdpClient(a2_id, a2_localPort);

            Assert.IsNotNull(ComService.GetClient(a2_id));
            ComService.RemoveClient(a2_id);
            Assert.IsNull(ComService.GetClient(a2_id));

            ComService.RemoveClient(a1_id);
        }
        public void TestInitialize()
        {
            ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, 0);
            ConversationManager.Start(null);

            //create fake portfolios to populate leaderboard
            PortfolioManager.TryToCreate("port1", "pass1", out Portfolio port);
            PortfolioManager.PerformTransaction(port.PortfolioID, user1VStock.Symbol, 1, 1, out port, out string error);

            PortfolioManager.TryToCreate("port2", "pass2", out port);
            PortfolioManager.PerformTransaction(port.PortfolioID, user2VStock.Symbol, 1, 1, out port, out error);

            PortfolioManager.TryToCreate("port3", "pass3", out port);
            PortfolioManager.PerformTransaction(port.PortfolioID, user3VStock.Symbol, 1, 1, out port, out error);

            //clear connected clients (if any leftover from other tests)
            ClientManager.Clients.Clear();
        }
Esempio n. 8
0
 public void TestInitialize()
 {
     ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, 0);
     ConversationManager.Start(null);
 }
Esempio n. 9
0
 public void TestInitialize()
 {
     PortfolioManager.Clear();
     ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, 0);
     ConversationManager.Start(ConversationBuilder);
 }