Exemplo n.º 1
0
        private void RunServer()
        {
            var supportedVersions = new List <EtpVersion> {
                EtpVersion.v11, EtpVersion.v12
            };
            var supportedEncodings = new List <EtpEncoding> {
                EtpEncoding.Binary, EtpEncoding.Json
            };
            var serverDetails = new EtpWebServerDetails(supportedVersions, supportedEncodings);
            var endpointInfo  = EtpFactory.CreateServerEndpointInfo(ServerAppName, AppVersion);

            using (var webServer = EtpFactory.CreateSelfHostedWebServer(WebSocketType.Native, ServerPort, endpointInfo, details: serverDetails))
            {
                webServer.ServerManager.ServerCreated += OnServerCreated;
                InitializeWebServer(webServer);
                HandleWebServer(webServer);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EtpServerManager"/> class.
 /// </summary>
 /// <param name="webServerDetails">The web server details.</param>
 /// <param name="endpointInfo">The server manager's endpoint information.</param>
 /// <param name="endpointParameters">The server manager's endpoint parameters.</param>
 public EtpServerManager(EtpWebServerDetails webServerDetails, EtpEndpointInfo endpointInfo, EtpEndpointParameters endpointParameters = null)
     : base(webServerDetails, endpointInfo, endpointParameters)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EtpSocketServer"/> class.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <param name="endpointInfo">The web server's endpoint information.</param>
        /// <param name="endpointParameters">The web server's endpoint parameters.</param>
        /// <param name="details">The web server's details.</param>
        public EtpSelfHostedWebServer(int port, EtpEndpointInfo endpointInfo, EtpEndpointParameters endpointParameters = null, EtpWebServerDetails details = null)
        {
            Logger = LogManager.GetLogger(GetType());

            Details       = details ?? new EtpWebServerDetails();
            ServerManager = new EtpServerManager(Details, endpointInfo, endpointParameters);

            Uri = new Uri($"http://localhost:{port}");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EtpSelfHostedWebServer"/> class.
        /// </summary>
        /// <param name="port">The port.</param>
        /// <param name="endpointInfo">The web server's endpoint information.</param>
        /// <param name="endpointParameters">The web server's endpoint parameters.</param>
        /// <param name="details">The web server's details.</param>
        public EtpSelfHostedWebServer(int port, EtpEndpointInfo endpointInfo, EtpEndpointParameters endpointParameters = null, EtpWebServerDetails details = null)
        {
            Logger = LogManager.GetLogger(GetType());

            Details       = details ?? new EtpWebServerDetails();
            ServerManager = new EtpServerManager(Details, endpointInfo, endpointParameters);

            _server = new WebSocketServer(Details.SupportedVersions.Select(v => new BasicSubProtocol(EtpFactory.GetSubProtocol(v))));

            _server.Setup(new ServerConfig
            {
                Ip               = "Any",
                Port             = port,
                MaxRequestLength = int.MaxValue,
            });

            _server.NewSessionConnected += OnNewSessionConnected;
            _server.NewDataReceived     += OnNewDataReceived;
            _server.SessionClosed       += OnSessionClosed;

            Uri = new Uri($"http://localhost:{port}");
        }