       self.emit(.connectionClose)
     }
     
-    #if !os(Linux)
-    self.session?.disconnect()
-    #else
-    try? self.session?.close()
-    #endif
-    
-    try? self.udpClient?.close()
-    
     self.heartbeat = nil
     self.isConnected = false
     self.encoder = nil
+    
+    #if !os(Linux)
+    self.session?.disconnect()
+    #else
+    try? self.session?.close()
+    #endif
+    
+    try? self.udpClient?.close()
   }
 
 }


    process.standardOutput = self.writer

    process.terminationHandler = { [unowned self] _ in
      self.finish()
    }

    process.launch()

  */
  func handleDisconnect(for code: Int) {
    guard CloseOP(rawValue: code) != nil else {
      return
    }
  }
