Exemple #1
0
        private WebSocketTransmissionServer(WebSocketTransmissionServerOptions options, string protocol)
        {
            _options  = options;
            _protocol = protocol;
            var serverName = $"{protocol}-v1";

            _stateWriter = new ServerStateWriter(serverName, _options.WorkingDir);
            _buffer.Out.PropagateCompletionFrom(Completion);
        }
Exemple #2
0
        public Broker(BrokerOptions options, IRegistryProvider registryProvider = null)
        {
            _workingDir = Directory.GetCurrentDirectory();
            var binDir    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var studioDir = Path.Combine(binDir, "studio");

            Log.Info("Studio dir: {0}", studioDir);
            var metadataDir = Path.GetFullPath(options.MetadataDir ?? Path.Combine(_workingDir, "metadata"));

            Log.Info("Metadata dir: {0}", metadataDir);
            var metadataFile = Path.Combine(metadataDir, "interop.json");
            var webSocketTransmissionServerOptions = new WebSocketTransmissionServerOptions(
                _workingDir,
                options.Port,
                new Dictionary <string, string>
            {
                { "/metadata/interop", metadataFile },
                { "/studio", studioDir }
            });

            _transportServers = new[]
            {
                TransportServerFactory.Instance.Create(
                    PipeTransmissionServerFactory.Instance.Create(_workingDir),
                    DefaultTransportSerializationProvider),
                TransportServerFactory.Instance.Create(
                    WebSocketTransmissionServerFactory.Instance.Create(webSocketTransmissionServerOptions),
                    DefaultTransportSerializationProvider)
            };
            _connectionListener  = new ServerConnectionListener(_transportServers);
            registryProvider     = registryProvider ?? JsonRegistryProvider.Initialize(Path.Combine(metadataDir, "interop.json"));
            _appLifecycleManager = AppLifecycleManagerFactory.Instance.Create(metadataDir);
            _brokerProcessor     = BrokerProcessorFactory.Instance.Create(
                _connectionListener.In,
                registryProvider,
                DefaultProtocolSerializationProvider,
                _appLifecycleManager);
            OnStop(_connectionListener.Stop);
        }
Exemple #3
0
 public WebSocketTransmissionServer(WebSocketTransmissionServerOptions options)
 {
     _options     = options;
     _stateWriter = new ServerStateWriter(ServerName, _options.WorkingDir);
     _buffer.Out.PropagateCompletionFrom(Completion);
 }
Exemple #4
0
        public Broker(BrokerOptions options, IRegistryProvider registryProvider = null)
        {
            _features = EnvironmentHelper.GetBrokerFeatures();
            Log.Info($"Broker features: {_features}");
            var trustedLauncherId = EnvironmentHelper.GetLauncherAppInstanceId();

            Log.Info($"App launcher application instance id: {trustedLauncherId}");
            if (_features.HasFlag(BrokerFeatures.CheckAppInstanceId) && trustedLauncherId == null)
            {
                throw new BrokerException($"{EnvironmentHelper.LauncherId} must be defined if {BrokerFeatures.CheckAppInstanceId} set.");
            }
            _workingDir = Directory.GetCurrentDirectory();
            var binDir    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var studioDir = Path.Combine(binDir, "studio");

            Log.Info("Studio dir: {0}", studioDir);
            var metadataDir = Path.GetFullPath(options.MetadataDir ?? Path.Combine(_workingDir, "metadata"));

            Log.Info("Metadata dir: {0}", metadataDir);
            var metadataFile = Path.Combine(metadataDir, "interop.json");
            IReadOnlyDictionary <string, string> staticFileMapping = new Dictionary <string, string>
            {
                { "/metadata/interop", metadataFile },
                { "/studio", studioDir }
            };
            var webSocketTransmissionServerOptions = new WebSocketTransmissionServerOptions(_workingDir, options.Port, staticFileMapping);
            var transportServers = new List <ITransportServer>
            {
                TransportServerFactory.Instance.Create(
                    TransportType.Pipe,
                    PipeTransmissionServerFactory.Instance.Create(_workingDir),
                    DefaultTransportSerializationProvider),
                TransportServerFactory.Instance.Create(
                    TransportType.Ws,
                    WebSocketTransmissionServerFactory.Instance.Create(webSocketTransmissionServerOptions),
                    DefaultTransportSerializationProvider),
            };

            if (_features.HasFlag(BrokerFeatures.UseWSS))
            {
                var certificate = GetCertificate();
                if (certificate != null)
                {
                    var wssTransmissionServerOptions = new WebSocketTransmissionServerOptions(_workingDir, options.WssPort, staticFileMapping);
                    var sslProtocols = EnvironmentHelper.GetSslProtocols();
                    Log.Info($"{EnvironmentHelper.SslProtocols}={sslProtocols}");
                    transportServers.Add(TransportServerFactory.Instance.Create(
                                             TransportType.Wss,
                                             WebSocketTransmissionServerFactory.Instance.CreateSecure(wssTransmissionServerOptions, certificate, sslProtocols),
                                             DefaultTransportSerializationProvider));
                }
            }
            _transportServers   = transportServers;
            _connectionListener = new ServerConnectionListener(_transportServers);
            registryProvider    = registryProvider ?? new JsonRegistryProvider(Path.Combine(metadataDir, "interop.json"));
            _interopContext     = InteropContextFactory.Instance.Create(trustedLauncherId ?? default, metadataDir, registryProvider);
            _brokerProcessor    = BrokerProcessorFactory.Instance.Create(
                _connectionListener.In,
                DefaultProtocolSerializationProvider,
                _interopContext,
                _features);
            OnStop(_connectionListener.Stop);
        }
Exemple #5
0
 public WebSocketTransmissionServer(WebSocketTransmissionServerOptions options, X509Certificate2 certificate, SslProtocols sslProtocols)
     : this(options, "wss")
 {
     _certificate  = certificate;
     _sslProtocols = sslProtocols;
 }
Exemple #6
0
 public WebSocketTransmissionServer(WebSocketTransmissionServerOptions options)
     : this(options, "ws")
 {
 }