static void Main(string[] args)
        {
            //__clientTest.__main__();

            /****** A@Mary START ******/                              // Code block 1
            var postoffice1 = new ClientPostOffice();
            var agent1      = postoffice1.Connect("127.0.0.1", 1350); // create a client agent with specified server IP and port

            agent1.Login("Mary", "", 10000);                          // login with account 'Mary' without password
            var objA = new SignalStation("A");                        // create a 'SignalStation' instance named 'A'
            var boxA = postoffice1.Register(objA);                    // register a mailbox for 'A' to grant it to communicate with other entities
            /****** A@Mary END ******/

            /****** B@Tom START ******/  // Code block 2
            var postoffice2 = new ClientPostOffice();
            var agent2      = postoffice2.Connect("127.0.0.1", 1350);

            agent2.Login("Tom", "", 10000);
            var objB = new SignalStation("B");
            var boxB = postoffice2.Register(objB);

            /****** B@Tom END ******/

            // 'B' send a message to 'A'
            //var result = boxB.Get("A@Mary", "hello A!", "put the content here.");
            boxB.Post("A@Mary", "hello A!", "put the content here.");
            // or send a serializable object
            boxA.Post("B@Tom", "hello B, this is a information card of Jerry!", new Person(20, "Jerry"));

            Console.ReadKey();
        }
示例#2
0
        public ClientAgentSimulator(ClientPostOffice postOffice)
        {
            this.nowBlock   = new TimeBlock();
            this.postOffice = postOffice;

            // create server login agent simulator
            this.serverLoginAgentSimulator = new ServerAgentSimulator(this);
        }
示例#3
0
        public static void __main__()
        {
            DuplicateLoginTest();

            var office = new ClientPostOffice("");
            var agent  = office.Connect("127.0.0.1", 1350);

            var ea  = new Entity("A");
            var mba = office.Register(ea);

            mba.Get("A@localhost", "hellpA", "fire in the hole");

            Console.ReadKey(false);
        }
示例#4
0
        static void DuplicateLoginTest()
        {
            /****** A@Mary START ******/                              // Code block 1
            var postoffice1 = new ClientPostOffice();
            var agent1      = postoffice1.Connect("127.0.0.1", 1350); // create a client agent with specified server IP and port

            agent1.Login("Mary", "", 10000);                          // login with account 'Mary' without password
            /****** A@Mary END ******/

            /****** B@Tom START ******/  // Code block 2
            var postoffice2 = new ClientPostOffice();
            var agent2      = postoffice2.Connect("127.0.0.1", 1350);

            agent2.Login("Mary", "", 10000);

            var mb = postoffice1.Register(new Entity("CBV"));

            Console.ReadLine();
        }
示例#5
0
 public void Dispose()
 {
     this.serverLoginAgentSimulator = null;
     this.postOffice = null;
 }