Пример #1
0
        /// <summary>
        /// Creates an <see cref="IEtpSelfHostedWebServer"/> instance.
        /// </summary>
        /// <param name="port">The port number.</param>
        /// <returns>A new <see cref="IEtpSelfHostedWebServer"/> instance.</returns>
        protected IEtpSelfHostedWebServer CreateServer(int port)
        {
            var version = GetType().Assembly.GetName().Version.ToString();
            var server  = EtpFactory.CreateSelfHostedWebServer(port, GetType().AssemblyQualifiedName, version);

            return(server);
        }
Пример #2
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);
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes the ETP client.
        /// </summary>
        public void InitEtpServer()
        {
            try
            {
                Runtime.Invoke(() => Runtime.Shell.StatusBarText = "Listening...");

                var message = $"Listening for ETP connections on port {Model.PortNumber}...";
                LogClientOutput(message, true);
                _log.Debug(message);

                SelfHostedWebServer = EtpFactory.CreateSelfHostedWebServer(Model.PortNumber, Model.ApplicationName, Model.ApplicationVersion);
                SelfHostedWebServer.SessionConnected += OnServerSessionConnected;
                SelfHostedWebServer.SessionClosed    += OnServerSessionClosed;
                SelfHostedWebServer.Start();
            }
            catch (Exception ex)
            {
                Runtime.Invoke(() => Runtime.Shell.StatusBarText = "Error");
                Runtime.ShowError("Error initializing ETP server.", ex);
            }
        }
Пример #4
0
        private async Task InitChannelStreaming(CancellationToken token)
        {
            using (var server = EtpFactory.CreateSelfHostedWebServer(Model.PortNumber, ((IScreen)Parent).DisplayName, Model.Version))
            {
                var simulator = CreateEtpSimulator();
                simulator.Register(server);
                server.Start();

                Log("ETP Socket Server started, listening on port {0}.", Model.PortNumber);

                while (true)
                {
                    await Task.Delay(250, token);

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                }
            }
        }