/// <summary> /// Initializes a new instance of the <see cref="SMSession"/> class. /// </summary> /// <param name="uri">the URI.</param> /// <param name="isServer">the Server flag.</param> public SMSession(Uri uri, bool isServer) { this.streams = new List<SMStream>(); this.closedStreams = new List<SMStream>(); this.isServer = isServer; this.protocol = new SMProtocol(uri, this); this.protocol.OnSessionFrame += this.OnSessionFrame; this.protocol.OnClose += this.OnProtocolClose; this.protocol.OnOpen += this.OnProtocolOpen; this.protocol.OnError += this.OnProtocolError; this.protocol.OnPing += this.OnProtocolPing; }
/// <summary> /// Initializes a new instance of the <see cref="SMSession"/> class. /// </summary> /// <param name="uri">the URI.</param> /// <param name="isServer">the Server flag.</param> /// <param name="options">Session options.</param> public SMSession(Uri uri, bool isServer, SMProtocolOptions options) { this.isFlowControlEnabled = options.IsFlowControl; this.CreditAddition = options.CreditAddition; this.CurrentCreditBalanceFromServer = Convert.ToInt64(CreditAddition); this.CurrentCreditBalanceToServer = Convert.ToInt64(CreditAddition); this.streams = new List <SMStream>(); this.closedStreams = new List <SMStream>(); this.isServer = isServer; this.protocol = new SMProtocol(uri, this, options); this.protocol.OnSessionFrame += this.OnSessionFrame; this.protocol.OnClose += this.OnProtocolClose; this.protocol.OnOpen += this.OnProtocolOpen; this.protocol.OnError += this.OnProtocolError; this.protocol.OnPing += this.OnProtocolPing; if (options.UseCompression) { this.Protocol.SetProcessors(new List <IMessageProcessor> { new CompressionProcessor() }); } }