 	case stop
 	case start
 	case unpause
+	case volume
 }
 
 struct DockerEvent: CustomStringConvertible {

				eventType = .stop
			case "unpause":
				eventType = .unpause
			default:
				return nil
		}

	init(baseUrl: URL, delegate: DockerEventMonitorDelegate, sessionConfig: URLSessionConfiguration)
}

final class DockerEventMonitorImpl: DockerEventMonitor
{
	weak var delegate: DockerEventMonitorDelegate?
	var connection: LocalDockerConnection!

	required init(baseUrl: URL, delegate: DockerEventMonitorDelegate, sessionConfig: URLSessionConfiguration)
	{
		self.delegate = delegate
		let request = URLRequest(url: baseUrl.appendingPathComponent("/events").absoluteURL)
		self.connection = LocalDockerConnectionImpl<HijackedResponseHandler>(request: request, handler: connectionCallback)
		connection.openConnection()
		connection.writeRequest()
	}

	func connectionCallback(message: LocalDockerMessage) {
		switch message {
		case .headers(let headers):
			assert(headers.statusCode == 200)
		case .data(let data):
			handleData(data: data)
		case .complete:
			os_log("docker event monitor connection ended", log: .docker, type: .info)
			delegate?.eventMonitorClosed(error: nil)
		case .error(let error):
			os_log("error from docker event connection: %{public}@", log: .docker, error.debugDescription)
			delegate?.eventMonitorClosed(error: error)
		}
	}
	
	private func handleData(data: Data) {
		do {
			let json = try JSON(data: data)
			guard let event = DockerEvent(json) else {
				os_log("got invalid event from docker: %{public}@", log: .docker, type: .debug, String(data: data, encoding: .utf8)!)
				return
			}
			delegate?.handleEvent(event)
		} catch {
			os_log("error parsing docker event: %{public}@", log: .docker, error.localizedDescription)
		}
	}
}
