Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update client.proto file. Update sendRPC method #33

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/SwiftCentrifuge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-SwiftCentrifuge_Example/Pods-SwiftCentrifuge_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-SwiftCentrifuge_Example/Pods-SwiftCentrifuge_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework",
"${BUILT_PRODUCTS_DIR}/SwiftCentrifuge/SwiftCentrifuge.framework",
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
Expand All @@ -325,7 +325,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftCentrifuge_Example/Pods-SwiftCentrifuge_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftCentrifuge_Example/Pods-SwiftCentrifuge_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
9 changes: 6 additions & 3 deletions Sources/SwiftCentrifuge/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ public class CentrifugeClient {
}
}


/**
Send RPC command
- parameter method: String
- parameter data: Data
- parameter completion: Completion block
*/
public func rpc(data: Data, completion: @escaping (Data?, Error?)->()) {
public func rpc(method: String = "", data: Data, completion: @escaping (Data?, Error?)->()) {
self.syncQueue.async { [weak self] in
guard let strongSelf = self else { return }
strongSelf.waitForConnect(completion: { [weak self] error in
Expand All @@ -152,7 +154,7 @@ public class CentrifugeClient {
completion(nil, err)
return
}
strongSelf.sendRPC(data: data, completion: {result, error in
strongSelf.sendRPC(method: method, data: data, completion: {result, error in
if let err = error {
completion(nil, err)
return
Expand Down Expand Up @@ -937,9 +939,10 @@ fileprivate extension CentrifugeClient {
}
}

private func sendRPC(data: Data, completion: @escaping (Proto_RPCResult?, Error?)->()) {
private func sendRPC(method: String, data: Data, completion: @escaping (Proto_RPCResult?, Error?)->()) {
var params = Proto_RPCRequest()
params.data = data
params.method = method
do {
let paramsData = try params.serializedData()
let command = newCommand(method: .rpc, params: paramsData)
Expand Down
Loading