     qos: .userInitiated
   )
 
-  public init() {
-  }
+  public init() {}
 
   public func send(
     msgid: Int32,
     data: Data?,
     expectsReply: Bool
   ) -> Single<Data?> {
-    return Single.create { single in
+    Single.create { single in
       self.queue.async {
         self.portLock.withReadLock {
           guard self.portIsValid else {

  }

  public var syncReplyBody: SyncReplyBody? {
    get {
      return self.messageHandler.syncReplyBody
    }
    set {
      self.messageHandler.syncReplyBody = newValue
    }
  }

  public var stream: Observable<Message> {
    return self.streamSubject.asObservable()
  }

  public var queue = DispatchQueue(
    label: String(reflecting: RxMessagePortServer.self),
    qos: .userInitiated
  )

  public init() {
    self.messageHandler = MessageHandler(subject: self.streamSubject)
  }

  public func run(as name: String) -> Completable {
    return Completable.create { completable in
      self.queue.async {
        var localCtx = CFMessagePortContext(
          version: 0,


    public static func responseCodeToString(code: Int32) -> String {
      switch code {
      case kCFMessagePortSendTimeout:return "kCFMessagePortSendTimeout"
      case kCFMessagePortReceiveTimeout:return "kCFMessagePortReceiveTimeout"
      case kCFMessagePortIsInvalid:return "kCFMessagePortIsInvalid"
      case kCFMessagePortTransportError:return "kCFMessagePortTransportError"
      case kCFMessagePortBecameInvalidError:return "kCFMessagePortBecameInvalidError"
      default:return "unknown"
      }
    }
  }
