mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 03:25:03 +03:00
Reformat
This commit is contained in:
parent
a5814366b5
commit
e568295f68
@ -137,6 +137,7 @@ public final class RxMsgpackRpc {
|
||||
)
|
||||
|
||||
if expectsReturnValue {
|
||||
// In streamQueue since we want to sync' access self.singles only in that queue.
|
||||
self?.streamQueue.async { self?.singles[msgid] = single }
|
||||
}
|
||||
|
||||
@ -163,6 +164,9 @@ public final class RxMsgpackRpc {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
||||
// R/w only in self.queue
|
||||
private var nextMsgid: UInt32 = 0
|
||||
|
||||
private let queue: DispatchQueue
|
||||
@ -237,6 +241,7 @@ public final class RxMsgpackRpc {
|
||||
}
|
||||
}
|
||||
|
||||
// Call only in self.streamQueue
|
||||
private func processMessage(_ unpacked: Value) {
|
||||
guard let array = unpacked.arrayValue else {
|
||||
self.streamSubject.onNext(.error(
|
||||
@ -300,6 +305,21 @@ public final class RxMsgpackRpc {
|
||||
}
|
||||
}
|
||||
|
||||
// Call only in self.streamQueue
|
||||
private func processResponse(msgid: UInt32, error: Value, result: Value) {
|
||||
if let single = self.singles.removeValue(forKey: msgid) {
|
||||
single(.success(Response(msgid: msgid, error: error, result: result)))
|
||||
}
|
||||
|
||||
if self.streamResponses {
|
||||
self.streamSubject.onNext(.response(msgid: msgid, error: error, result: result))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Private utilities
|
||||
|
||||
extension RxMsgpackRpc {
|
||||
private func unpackAllWithRemainder(_ data: Data) throws -> (values: [Value], remainder: Data?) {
|
||||
var values = [Value]()
|
||||
var remainderData: Data?
|
||||
@ -318,16 +338,6 @@ public final class RxMsgpackRpc {
|
||||
|
||||
return (values, remainderData)
|
||||
}
|
||||
|
||||
private func processResponse(msgid: UInt32, error: Value, result: Value) {
|
||||
if let single = self.singles.removeValue(forKey: msgid) {
|
||||
single(.success(Response(msgid: msgid, error: error, result: result)))
|
||||
}
|
||||
|
||||
if self.streamResponses {
|
||||
self.streamSubject.onNext(.response(msgid: msgid, error: error, result: result))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private typealias SingleResponseObserver = (SingleEvent<RxMsgpackRpc.Response>) -> Void
|
||||
|
Loading…
Reference in New Issue
Block a user