Example #1
0
        private void OnCloseConnection(object sender, ConnectionCloseEventArgs e)
        {
            var connection = (IConnection)sender;

            connection.Closed -= CloseConnection;
            EventRaiser.SoftRaiseEvent(CloseConnection, this, e);
            connectionListenerMap.Remove(connection.Id);
        }
Example #2
0
 protected void RaiseReceived(byte[] buffer, int offset, int count)
 {
     EventRaiser.SoftRaiseEvent(
         Received,
         this,
         new ConnectionBufferEventArgs(this, buffer, offset, count)
         );
 }
Example #3
0
        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();
        }
Example #4
0
        public void Close(ConnectionCloseReason reason)
        {
            lock (this)
            {
                if (IsClosed)
                {
                    return;
                }
                IsClosed = true;

                EventRaiser.SoftRaiseEvent(Closed, this, new ConnectionCloseEventArgs(this, reason));

                OnClose(reason);
            }
        }
Example #5
0
 private void OnOpenConnection(object sender, ConnectionOpenEventArgs e)
 {
     connectionListenerMap[e.Connection.Id] = ((IListener)sender).Name;
     e.Connection.Closed += OnCloseConnection;
     EventRaiser.SoftRaiseEvent(OpenConnection, this, e);
 }