public virtual void Dispose() { foreach (var entry in connectionMap) { reactor?.RemoveHandler(entry.Value, EventType.CONNECT_EVENT); entry.Key?.Dispose(); entry.Value?.Dispose(); } }
protected virtual void Complete(IServiceHandler handler, ConnectionResult result) { if (connectionMap.ContainsKey(handler.Handle)) { IServiceHandler serviceHandler = connectionMap[handler.Handle]; reactor.RemoveHandler(serviceHandler, EventType.CONNECT_EVENT); serviceHandler.ConnectionNotification -= Complete; connectionMap.Remove(handler.Handle); if (result == ConnectionResult.SUCCESS) { log.Info("Socket Address {0} connected. Removed from Reactor and Connection map", ((IPEndPoint)handler.Handle.RemoteEndPoint).ToString()); ActivateServiceHandler(serviceHandler); } else { this.Dispose(); } } else { log.Warn("Connection map does not contain handle for address {0}", ((IPEndPoint)handler.Handle.RemoteEndPoint).ToString()); } }
virtual public void Dispose() { reactor?.RemoveHandler(this, EventType.READ_EVENT & EventType.WRITE_EVENT); Handle?.Dispose(); log.Info("SocketServiceHandler disposed"); }