Esempio n. 1
0
        public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry)
        {
            var inContext = new Context();

            inContext.TemplateRegistry.RegisterAll(inboundRegistry);
            var outContext = new Context();

            outContext.TemplateRegistry.RegisterAll(outboundRegistry);
            inContext.ErrorHandler = this;

            this.connection = connection;
            this.protocol   = protocol;
            try
            {
                in_stream  = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                out_stream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (System.IO.IOException e)
            {
                errorHandler.Error(null, "Error occurred in connection.", e);
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }
Esempio n. 2
0
        public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry)
        {
            var inContext = new Context();
            inContext.TemplateRegistry.RegisterAll(inboundRegistry);
            var outContext = new Context();
            outContext.TemplateRegistry.RegisterAll(outboundRegistry);
            inContext.ErrorHandler = this;

            this.connection = connection;
            this.protocol = protocol;
            try
            {
                in_stream = new MessageInputStream(connection.InputStream.BaseStream, inContext);
                out_stream = new MessageOutputStream(connection.OutputStream.BaseStream, outContext);
            }
            catch (System.IO.IOException e)
            {
                errorHandler.Error(null, "Error occurred in connection.", e);
                throw new IllegalStateException(e);
            }

            protocol.ConfigureSession(this);
        }