コード例 #1
0
        public InterCcCommunicationServer(NCC ncc)
        {
            this.ncc  = ncc;
            ipAddress = Dns.GetHostEntry(ip).AddressList[0];
            server    = new TcpListener(ipAddress, port);
            server.Start();

            new Thread(StartListening).Start();
        }
コード例 #2
0
        public ParentConnection(TcpClient client, NCC ncc)
        {
            this.client = client;
            this.ncc    = ncc;
            stream      = client.GetStream();
            reader      = new StreamReader(stream);
            writer      = new StreamWriter(stream);

            new Thread(RecieveMessages).Start();
        }
コード例 #3
0
        public Server(NCC ncc)
        {
            this.ncc  = ncc;
            ipAddress = Dns.GetHostEntry(ip).AddressList[0];
            server    = new TcpListener(ipAddress, port);
            //TODO: tu jakiś konfig wczytujemy

            GUIWindow.PrintLog("Control center is waiting for connections...");
            server.Start();

            new Thread(StartListening).Start();
        }
コード例 #4
0
        public HostConnection(Host host, TcpClient client, int id, Server server, NCC ncc)
        {
            this.host   = host;
            this.client = client;
            this.id     = id;
            this.server = server;
            this.ncc    = ncc;

            stream = client.GetStream();
            reader = new StreamReader(stream);
            writer = new StreamWriter(stream);

            new Thread(RecieveMessages).Start();
        }
コード例 #5
0
        static void Main(String[] args)
        {
            try {
                args = Environment.GetCommandLineArgs();

                new Thread(() => {
                    Thread.Sleep(1000);
                    try {
                        String config = String.Concat(File.ReadAllLines(args[1]));
                        ConfigLoader.loadConfig(config, args[2]);

                        //String config = String.Concat(File.ReadAllLines("./../../../../sharedResources/tsst_config.xml"));
                        //ConfigLoader.loadConfig(config, "1");


                        //String config = String.Concat(File.ReadAllLines("./../../../../sharedResources/tsst_config.xml"));
                        //ConfigLoader.loadConfig(config);
                        //String config = String.Concat(File.ReadAllLines(args[1]));
                        //ConfigLoader.LoadConfig(config, args[2]);
                        ncc    = new NCC();
                        server = new Server(ncc);

                        if (ConfigLoader.ccID == 2)
                        {
                            interCCServer = new InterCcCommunicationServer(ncc);
                        }
                        else if (ConfigLoader.ccID == 1)
                        {
                            peerConnection = new PeerConnection(new TcpClient("localhost", 12500), true, ncc);
                        }
                        else
                        {
                            childConnection = new ChildConnection(new TcpClient("localhost", 12500), ncc);
                        }
                        GUIWindow.UpdateChannelTable();
                    }
                    catch (Exception e) {
                        GUIWindow.PrintLog(e.StackTrace);
                    }
                }).Start();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUIWindow());
            }
            catch (Exception ex) {
                GUIWindow.PrintLog(ex.StackTrace);
            }
        }
コード例 #6
0
        public PeerConnection(TcpClient client, bool register, NCC ncc)
        {
            this.client = client;
            this.ncc    = ncc;
            stream      = client.GetStream();
            reader      = new StreamReader(stream);
            writer      = new StreamWriter(stream);

            if (register)
            {
                Register();
            }

            new Thread(RecieveMessages).Start();
            //try {
            //    new Thread(() => {
            //        Thread.Sleep(100);
            //        Program.rc.SendNetworkTopology();
            //    }).Start();
            //} catch(Exception e) {
            //    GUIWindow.PrintLog(e.Message);
            //    GUIWindow.PrintLog(e.StackTrace);
            //}
        }