public FreeSwitchServer() {
     var config = new ChannelTcpListenerConfiguration(() => new FreeSwitchDecoder(), () => new FreeSwitchEncoder());
     _listener = new FreeSwitchListener(config);
     _listener.MessageReceived += OnClientMessage;
     _listener.ClientConnected += OnClientConnect;
     _listener.ClientDisconnected += OnClientDisconnect;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpListener"/> class.
        /// </summary>
        public HttpListener()
        {
            var config = new ChannelTcpListenerConfiguration(
                () => BodyDecoder == null ? new HttpMessageDecoder() : new HttpMessageDecoder(BodyDecoder),
                () => new HttpMessageEncoder());

            Configure(config);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpListener"/> class.
        /// </summary>
        public HttpListener()
        {
            var config = new ChannelTcpListenerConfiguration(
                () => new HttpMessageDecoder(BodyDecoder),
                () => new HttpMessageEncoder());

            Configure(config);
        }
        /// <summary>
        ///     Create a new instance of  <see cref="WebSocketListener" />.
        /// </summary>
        public WebSocketListener()
        {
            var config = new ChannelTcpListenerConfiguration(
                () => new WebSocketDecoder(),
                () => new WebSocketEncoder());

            Configure(config);
        }
Exemple #5
0
        /// <summary>
        ///     Create a new instance of  <see cref="WebSocketListener" />.
        /// </summary>
        public WebSocketListener()
        {
            var config = new ChannelTcpListenerConfiguration(
                () => new WebSocketDecoder(),
                () => new WebSocketEncoder());

            Configure(config);
        }
Exemple #6
0
        /// <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>
        public HttpServer(IModuleManager moduleManager)
        {
            _moduleManager = moduleManager;
            BodyDecoder    = new CompositeIMessageSerializer();

            _configuration   = new ChannelTcpListenerConfiguration(() => new HttpMessageDecoder(BodyDecoder), () => new HttpMessageEncoder());
            _bufferSlicePool = new BufferSlicePool(65535, 100);
            ApplicationInfo  = new MemoryItemStorage();
        }
        /// <summary>
        ///     Create a new instance of  <see cref="WebSocketListener" />.
        /// </summary>
        public WebSocketListener()
        {
            var config = new ChannelTcpListenerConfiguration(
                () => new WebSocketDecoder(),
                () => new WebSocketEncoder());

            Configure(config);
            _webSocketMessageReceived = delegate { };
        }
Exemple #8
0
        public FreeSwitchServer()
        {
            var config = new ChannelTcpListenerConfiguration(() => new FreeSwitchDecoder(), () => new FreeSwitchEncoder());

            _listener = new FreeSwitchListener(config);
            _listener.MessageReceived    += OnClientMessage;
            _listener.ClientConnected    += OnClientConnect;
            _listener.ClientDisconnected += OnClientDisconnect;
        }
        /// <summary>
        /// </summary>
        /// <param name="configuration"></param>
        public FreeSwitchListener(ChannelTcpListenerConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            Configure(configuration);
            ChannelFactory = new TcpChannelFactory();
            _channels      = new ConcurrentDictionary <string, ITcpChannel>();
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="LiteServer" /> class.
        /// </summary>
        public LiteServer(LiteServerConfiguration configuration)
        {
            if (configuration == null) throw new ArgumentNullException("configuration");

            _modules = configuration.Modules.Build();
            var config = new ChannelTcpListenerConfiguration(configuration.DecoderFactory, configuration.EncoderFactory);
            _listener = new ChannelTcpListener(config);
            if (configuration.Certificate != null)
                _listener.ChannelFactory =
                    new SecureTcpChannelFactory(new ServerSideSslStreamBuilder(configuration.Certificate));

            _listener.MessageReceived = OnClientMessage;
            _listener.ClientConnected += OnClientConnect;
            _listener.ClientDisconnected += OnClientDisconnect;
        }
Exemple #11
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="CqsServer" /> class.
        /// </summary>
        public CqsServer(ICommandBus commandBus, IQueryBus queryBus, IEventBus eventBus,
                         IRequestReplyBus requestReplyBus)
        {
            _commandBus      = commandBus;
            _queryBus        = queryBus;
            _eventBus        = eventBus;
            _requestReplyBus = requestReplyBus;

            var config = new ChannelTcpListenerConfiguration(CreateDecoder, CreateEncoder);

            _listener = new ChannelTcpListener(config);
            _listener.MessageReceived = OnClientMessage;
            _requestMethod            = GetType().GetMethod("ExecuteRequest", BindingFlags.NonPublic | BindingFlags.Instance);
            _commandMethod            = GetType().GetMethod("ExecuteCommand", BindingFlags.NonPublic | BindingFlags.Instance);
            _queryMethod = GetType().GetMethod("ExecuteQuery", BindingFlags.NonPublic | BindingFlags.Instance);
        }
Exemple #12
0
        /// <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.
        /// </param>
        /// <exception cref="System.ArgumentNullException">moduleManager/configuration</exception>
        public HttpServer(IModuleManager moduleManager, ChannelTcpListenerConfiguration configuration)
        {
            if (moduleManager == null)
            {
                throw new ArgumentNullException("moduleManager");
            }
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            BodyDecoder      = new CompositeIMessageSerializer();
            _moduleManager   = moduleManager;
            _configuration   = configuration;
            _bufferSlicePool = new BufferSlicePool(65535, 100);
            ApplicationInfo  = new MemoryItemStorage();
        }
Exemple #13
0
        static void Main(string[] args)
        {
            var config = new ChannelTcpListenerConfiguration(
                () => new MyProtocolDecoder(),
                () => new MyProtocolEncoder()
                );
            var server = new ChannelTcpListener(config);

            server.MessageReceived += OnServerMessageReceived;
            server.Start(IPAddress.Any, 0);


            ExecuteClient(server).Wait();

            Console.WriteLine("Demo completed");
            Console.ReadLine();
        }
Exemple #14
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="LiteServer" /> class.
        /// </summary>
        public LiteServer(LiteServerConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _modules = configuration.Modules.Build();
            var config = new ChannelTcpListenerConfiguration(configuration.DecoderFactory, configuration.EncoderFactory);

            _listener = new ChannelTcpListener(config);
            if (configuration.Certificate != null)
            {
                _listener.ChannelFactory =
                    new SecureTcpChannelFactory(new ServerSideSslStreamBuilder(configuration.Certificate));
            }

            _listener.MessageReceived     = OnClientMessage;
            _listener.ClientConnected    += OnClientConnect;
            _listener.ClientDisconnected += OnClientDisconnect;
        }
Exemple #15
0
        private static void Main(string[] args)
        {
            ObjectFactory.Configure(x => x.Scan(z =>
            {
                z.TheCallingAssembly();
                z.WithDefaultConventions();
                z.RegisterConcreteTypesAgainstTheFirstInterface();
            }));

            var settings = new ChannelTcpListenerConfiguration(
                () => new MicroMessageDecoder(new JsonSerializer()),
                () => new MicroMessageEncoder(new JsonSerializer()));

            var server = new MicroMessageTcpListener(settings)
            {
                MessageReceived = OnServerMessage
            };

            server.Start(IPAddress.Any, 1234);

            Console.WriteLine("Server started. Press any key to exit...");
            Console.ReadKey();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="configuration"></param>
 public MicroMessageTcpListener(ChannelTcpListenerConfiguration configuration)
     : base(configuration)
 {
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="configuration"></param>
 public MicroMessageTcpListener(ChannelTcpListenerConfiguration configuration)
     : base(configuration)
 {
 }
Exemple #18
0
 /// <summary>
 ///     Create a new instance of <see cref="WebSocketListener" />.
 /// </summary>
 /// <param name="configuration">Custom server configuration</param>
 public WebSocketListener(ChannelTcpListenerConfiguration configuration)
     : base(configuration)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpListener"/> class.
 /// </summary>
 /// <param name="configuration"></param>
 public HttpListener(ChannelTcpListenerConfiguration configuration) : base(configuration)
 {
 }
 /// <summary>
 ///     Create a new instance of <see cref="WebSocketListener" />.
 /// </summary>
 /// <param name="configuration">Custom server configuration</param>
 public WebSocketListener(ChannelTcpListenerConfiguration configuration)
     : base(configuration)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpListener"/> class.
 /// </summary>
 /// <param name="configuration"></param>
 public HttpListener(ChannelTcpListenerConfiguration configuration)
     : base(configuration)
 {
 }
 /// <summary>
 ///     To allow the sub classes to configure this class in their constructors.
 /// </summary>
 /// <param name="configuration"></param>
 protected void Configure(ChannelTcpListenerConfiguration configuration)
 {
     _bufferPool    = configuration.BufferPool;
     _configuration = configuration;
 }
 /// <summary>
 ///     To allow the sub classes to configure this class in their constructors.
 /// </summary>
 /// <param name="configuration"></param>
 protected void Configure(ChannelTcpListenerConfiguration configuration) {
     _bufferPool = configuration.BufferPool;
     _configuration = configuration;
 }
        /// <summary>
        /// </summary>
        /// <param name="configuration"></param>
        public ChannelTcpListener(ChannelTcpListenerConfiguration configuration) {
            if (configuration == null) throw new ArgumentNullException("configuration");

            Configure(configuration);
            ChannelFactory = new TcpChannelFactory();
        }