Skip to content
Snippets Groups Projects
Commit 125335d9 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Rename ServiceProcessor to Processor

parent 2fc6d1a4
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings import Bindings
import XCTestDynamicOverlay import XCTestDynamicOverlay
public struct ServiceProcessor { public struct Processor {
public struct Callback: Equatable { public struct Callback: Equatable {
public init(message: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) { public init(message: Data, receptionId: Data, ephemeralId: Int64, roundId: Int64) {
self.message = message self.message = message
...@@ -25,21 +25,21 @@ public struct ServiceProcessor { ...@@ -25,21 +25,21 @@ public struct ServiceProcessor {
public var process: (Callback) -> Void public var process: (Callback) -> Void
} }
extension ServiceProcessor { extension Processor {
public static let unimplemented = ServiceProcessor( public static let unimplemented = Processor(
serviceTag: "unimplemented", serviceTag: "unimplemented",
process: XCTUnimplemented("\(Self.self).process") process: XCTUnimplemented("\(Self.self).process")
) )
} }
extension ServiceProcessor { extension Processor {
func makeBindingsProcessor() -> BindingsProcessorProtocol { func makeBindingsProcessor() -> BindingsProcessorProtocol {
class Processor: NSObject, BindingsProcessorProtocol { class CallbackObject: NSObject, BindingsProcessorProtocol {
init(_ serviceProcessor: ServiceProcessor) { init(_ processor: Processor) {
self.serviceProcessor = serviceProcessor self.processor = processor
} }
let serviceProcessor: ServiceProcessor let processor: Processor
func process(_ message: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) { func process(_ message: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) {
guard let message = message else { guard let message = message else {
...@@ -48,7 +48,7 @@ extension ServiceProcessor { ...@@ -48,7 +48,7 @@ extension ServiceProcessor {
guard let receptionId = receptionId else { guard let receptionId = receptionId else {
fatalError("BindingsProcessor.process received `nil` receptionId") fatalError("BindingsProcessor.process received `nil` receptionId")
} }
serviceProcessor.process(Callback( processor.process(Callback(
message: message, message: message,
receptionId: receptionId, receptionId: receptionId,
ephemeralId: ephemeralId, ephemeralId: ephemeralId,
...@@ -57,10 +57,10 @@ extension ServiceProcessor { ...@@ -57,10 +57,10 @@ extension ServiceProcessor {
} }
func string() -> String { func string() -> String {
serviceProcessor.serviceTag processor.serviceTag
} }
} }
return Processor(self) return CallbackObject(self)
} }
} }
...@@ -2,10 +2,10 @@ import Bindings ...@@ -2,10 +2,10 @@ import Bindings
import XCTestDynamicOverlay import XCTestDynamicOverlay
public struct E2EAddService { public struct E2EAddService {
public var run: (ServiceProcessor) throws -> Void public var run: (Processor) throws -> Void
public func callAsFunction( public func callAsFunction(
processor: ServiceProcessor processor: Processor
) throws { ) throws {
try run(processor) try run(processor)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment