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();
        }
        public void Run()
        {
                var server = new MessagingServer(new MyHttpServiceFactory(),
                                                    new MessagingServerConfiguration(new HttpMessageFactory()));
                server.Start(new IPEndPoint(IPAddress.Loopback, 8888));

            Thread.Sleep(100000);

            }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer" /> class.
 /// </summary>
 /// <param name="moduleManager">The modules are used to process the HTTP requests. You need to specify at least one.</param>
 /// <param name="configuration">You can override the configuration to your likings. We suggest that you using the <see cref="HttpMessageFactory" /> to produce the messages.</param>
 /// <exception cref="System.ArgumentNullException">moduleManager/configuration</exception>
 public HttpServer(IModuleManager moduleManager, MessagingServerConfiguration configuration)
 {
     if (moduleManager == null) throw new ArgumentNullException("moduleManager");
     if (configuration == null) throw new ArgumentNullException("configuration");
     _moduleManager = moduleManager;
     _server = new MessagingServer(this, configuration);
     _bufferSliceStack = new BufferSliceStack(100, 65535);
     ApplicationInfo = new MemoryItemStorage();
     _workerConfiguration = new WorkerConfiguration
         {
             Application = ApplicationInfo,
             BufferSliceStack = _bufferSliceStack,
             ModuleManager = _moduleManager
         };
 }
        private void startServer()
        {
            tbPort.Enabled = false;

            bool error = false;
            try
            {
                port = Convert.ToInt16(tbPort.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bitte Zahl als Port angeben!");
            }

            try
            {
                mService = new DNSSDService();
            }
            catch
            {
                new BonjourErrorForm().ShowDialog();
                Application.Exit();
            }

            try
            {
                mRegistrar = mService.Register(0, 0, System.Environment.UserName, "_dvbctrl._tcp", "local", null, (ushort)this.port, null, mEventManager);
            }
            catch (Exception ex)
            {
                addLog(ex.Message);
            }

            if (!error)
            {
                try
                {
                    runServer.Visible = false;
                    stopServer.Visible = true;

                    listener = new MessagingServer(new DVBServiceFactory(this), new MessagingServerConfiguration(new HttpMessageFactory()));
                    listener.Start(new IPEndPoint(IPAddress.Any, port));

                    addLog("Server running on Port " + port.ToString() + "...");
                }
                catch (Exception ex)
                {
                    addLog(ex.Message);
                }
            }
        }
Beispiel #5
0
 public ChatServer()
 {
     var messageFactory = new BasicMessageFactory();
     var configuration = new MessagingServerConfiguration(messageFactory);
     _server = new MessagingServer(this, configuration);
 }
Beispiel #6
0
 /// <summary>
 /// Initialize and start the server.
 /// </summary>
 /// <param name="port"></param>
 /// <returns></returns>
 public static MessagingServer Create(int port)
 {
     var server = new MessagingServer(new NodeWebServerFactory(), new MessagingServerConfiguration(new HttpMessageFactory()));
     server.Start(new IPEndPoint(IPAddress.Any, port));
     return server;
 }
 public static void RunDemo()
 {
     var server = new MessagingServer(new MyHttpServiceFactory(),
                                      new MessagingServerConfiguration(new HttpMessageFactory()));
     server.Start(new IPEndPoint(IPAddress.Any, 8888));
 }
Beispiel #8
0
 public HttpServer()
 {
     Server = new MessagingServer(new HttpServiceWrappper.ServiceFactory(ListenerCallback),
         new MessagingServerConfiguration(new HttpMessageFactory()));
     LogRequests = false;
 }