Exemple #1
0
        public Shell(
            IKernel kernel,
            ICommandScheduler <JupyterRequestContext> scheduler,
            ConnectionInformation connectionInformation)
        {
            if (connectionInformation == null)
            {
                throw new ArgumentNullException(nameof(connectionInformation));
            }

            _kernel    = kernel ?? throw new ArgumentNullException(nameof(kernel));
            _scheduler = scheduler ?? throw new ArgumentNullException(nameof(scheduler));

            _shellAddress   = $"{connectionInformation.Transport}://{connectionInformation.IP}:{connectionInformation.ShellPort}";
            _ioPubAddress   = $"{connectionInformation.Transport}://{connectionInformation.IP}:{connectionInformation.IOPubPort}";
            _stdInAddress   = $"{connectionInformation.Transport}://{connectionInformation.IP}:{connectionInformation.StdinPort}";
            _controlAddress = $"{connectionInformation.Transport}://{connectionInformation.IP}:{connectionInformation.ControlPort}";

            var signatureAlgorithm = connectionInformation.SignatureScheme.Replace("-", string.Empty).ToUpperInvariant();

            _signatureValidator = new SignatureValidator(connectionInformation.Key, signatureAlgorithm);
            _shell       = new RouterSocket();
            _ioPubSocket = new PublisherSocket();
            _stdIn       = new RouterSocket();
            _control     = new RouterSocket();

            _shellChannel = new ReplyChannel(new MessageSender(_shell, _signatureValidator));
            _ioPubChannel = new PubSubChannel(new MessageSender(_ioPubSocket, _signatureValidator));
            _stdInChannel = new StdInChannel(new MessageSender(_stdIn, _signatureValidator), new MessageReceiver(_stdIn));

            _disposables = new CompositeDisposable
            {
                _shell,
                _ioPubSocket,
                _stdIn,
                _control
            };
        }
Exemple #2
0
 public MessageSender(IOutgoingSocket socket, SignatureValidator signatureValidator)
 {
     _socket             = socket ?? throw new ArgumentNullException(nameof(socket));
     _signatureValidator = signatureValidator ?? throw new ArgumentNullException(nameof(signatureValidator));
 }