/// <summary> /// Assign a socket to this channel /// </summary> /// <param name="socket">Connected socket</param> /// <remarks> /// the channel will start receive new messages as soon as you've called assign. /// </remarks> public void Assign(Socket socket) { if (socket == null) { throw new ArgumentNullException("socket"); } if (MessageReceived == null) { throw new InvalidOperationException("Must handle the MessageReceived callback before invoking this method."); } _stream = _sslStreamBuilder.Build(this, socket); _stream.BeginRead(_readBuffer.Buffer, _readBuffer.Offset, _readBuffer.Capacity, OnReadCompleted, null); }
/// <summary> /// Assign a socket to this channel /// </summary> /// <param name="socket">Connected socket</param> /// <remarks> /// the channel will start receive new messages as soon as you've called assign. /// </remarks> public void Assign(Socket socket) { if (socket == null) { throw new ArgumentNullException("socket"); } if (MessageReceived == null) { throw new InvalidOperationException("Must handle the MessageReceived callback before invoking this method."); } _socket = socket; RemoteEndpoint = socket.RemoteEndPoint; _stream = _sslStreamBuilder.Build(this, socket); ReadAsync(); }