private void OnCloseConnection(object sender, ConnectionCloseEventArgs e) { var connection = (IConnection)sender; connection.Closed -= CloseConnection; EventRaiser.SoftRaiseEvent(CloseConnection, this, e); connectionListenerMap.Remove(connection.Id); }
protected void RaiseReceived(byte[] buffer, int offset, int count) { EventRaiser.SoftRaiseEvent( Received, this, new ConnectionBufferEventArgs(this, buffer, offset, count) ); }
protected void AddNewConnection(IConnection connection) { if (connection == null) { throw new ArgumentNullException("connection"); } connections.Add(connection.Id, connection); connection.Closed += ConnectionClosed; EventRaiser.SoftRaiseEvent(OpenConnection, this, new ConnectionOpenEventArgs(connection, (IFormatter)Activator.CreateInstance(formatterType))); connection.BeginReceive(); }
public void Close(ConnectionCloseReason reason) { lock (this) { if (IsClosed) { return; } IsClosed = true; EventRaiser.SoftRaiseEvent(Closed, this, new ConnectionCloseEventArgs(this, reason)); OnClose(reason); } }
private void OnOpenConnection(object sender, ConnectionOpenEventArgs e) { connectionListenerMap[e.Connection.Id] = ((IListener)sender).Name; e.Connection.Closed += OnCloseConnection; EventRaiser.SoftRaiseEvent(OpenConnection, this, e); }