コード例 #1
0
 private void Run()
 {
     while (true)
     {
         if (EndPoint != null)
         {
             Console.WriteLine("Connecting to Registry Server");
             RegisterServerInitiator c = Factory.CreateFromConversationType <RegisterServerInitiator>();
             c.RemoteEndPoint = EndPoint;
             c.Server         = Server;
             c.Launch();
         }
         Thread.Sleep(10000);
     }
 }
コード例 #2
0
        public void ChatServerConversations()
        {
            ChatServerConversationFactory f;

            f = new ChatServerConversationFactory();
            Assert.IsNotNull(f);
            f.Initialize();

            // Test process initiator conversations
            HeartbeatInitiator test1 = f.CreateFromConversationType <HeartbeatInitiator>();

            Assert.IsNotNull(test1);
            test1.RemoteEndPoint = testEndpoint;
            test1.Launch();

            RegisterServerInitiator test2 = f.CreateFromConversationType <RegisterServerInitiator>();

            Assert.IsNotNull(test2);
            test2.RemoteEndPoint = testEndpoint;
            test2.Launch();
            Assert.AreEqual(test2.RemoteEndPoint, testEndpoint);

            // Test process responder conversations
            Envelope env1 = new Envelope();
            User     u    = new User();

            env1.Message = new ConnectToChatRequest(u);
            Responder resp1 = f.CreateFromEnvelope(env1);

            Assert.IsNotNull(resp1);
            Assert.AreEqual(resp1.ConversationId.ToString(), env1.Message.ConversationId.ToString());

            Envelope env2 = new Envelope();

            env2.Message = new HeartBeat(10000);
            Responder resp2 = f.CreateFromEnvelope(env2);

            Assert.IsNotNull(resp2);
            Assert.AreEqual(resp2.ConversationId.ToString(), env2.Message.ConversationId.ToString());
        }