 	}
 	
 	func pushMessageToQueue(_ encoder: MessageBuffer) {
-		messageQueue.orderedInsert(encoder) { $0.seq < $1.seq }
-		writeMoreData()
+		queue.async { 
+			self.messageQueue.orderedInsert(encoder) { $0.seq < $1.seq }
+			self.writeMoreData()
+		}
 	}
 
 	func logMessage(_ message: String?, filename: String?, lineNumber: Int?, functionName: String?, domain: String?, level: Int?) {

	*/
	var hostName: String?
	
	private var browser: NetServiceBrowser?
	
	private var service: NetService?

	
	func writeMoreData() {
		if let logStream = self.logStream {
			queue.async {
				if CFWriteStreamCanAcceptBytes(logStream) == true {
					if self.messageBeingSent == nil && self.messageQueue.count > 0 {
						self.messageBeingSent = self.messageQueue.remove(at: 0)
						self.sentCount = 0
					}
					if let msg = self.messageBeingSent {
						if self.sentCount < msg.count() {
							let ptr = msg.ptr().advanced(by: self.sentCount)
							let toWrite = msg.count() - self.sentCount
							let written = CFWriteStreamWrite(logStream, ptr, toWrite)
							if written < 0 {
								print("CFWriteStreamWrite returned error: \(written)")
							} else {
								self.sentCount = self.sentCount + written
								if self.sentCount == msg.count() {
									self.messageBeingSent = nil
								}
							}
						}
					}
