示例#1
0
        public static void RunDemo()
        {
            var server = new MessagingServer(new MyHttpServiceFactory(),
                                             new MessagingServerConfiguration(new HttpMessageFactory()));

            server.Start(new IPEndPoint(IPAddress.Loopback, 8888));
        }
示例#2
0
        private static void Main(string[] args)
        {
            // factory that produces our service classes which
            // will handle all incoming messages
            var serviceFactory = new MyServiceFactory();

            // factory used to create the classes that will
            // serialize and build our messages
            var messageFactory = new BasicMessageFactory();

            // server configuration.
            // you can limit the number of clients etc.
            var configuration = new MessagingServerConfiguration(messageFactory);

            // actual server
            var server = new MessagingServer(serviceFactory, configuration);

            server.Start(new IPEndPoint(IPAddress.Any, 7652));

            var client = new MessagingClient(messageFactory);

            client.Connect(new IPEndPoint(IPAddress.Loopback, 7652));

            // Look here! We receive objects!
            client.Received += (sender, eventArgs) => Console.WriteLine("We received: " + eventArgs.Message);

            // And here we are sending one.
            client.Send(new OpenDoor {
                Id = Guid.NewGuid().ToString()
            });

            //to prevent the server from shutting down
            Console.ReadLine();
        }
示例#3
0
 /// <summary>
 /// Start the HTTP server
 /// </summary>
 /// <param name="ipAddress">Address to listen on</param>
 /// <param name="port">Port to listen on.</param>
 public void Start(IPAddress ipAddress, int port)
 {
     if (ipAddress == null)
     {
         throw new ArgumentNullException("ipAddress");
     }
     _server.Start(new IPEndPoint(ipAddress, port));
 }
 public void Start()
 {
     _server.Start(new IPEndPoint(IPAddress.Any, 7652));
 }