Hello thanks for great library 🙌.
I'm trying to build wrapper library using LDSwiftEventSource internally on my react-native app.
However, I'm having problem with getting any events from server.
Logs are attached as screen shots below.
My questions are
Is this library issue or am I doing anything wrong?
Can I get callback for error below?
To reproduce
Here's my minimal code
import LDSwiftEventSource
@objc(EventSource)
class EventSource: NSObject {
private var connceted = false;
@objc(connect:options:)
func connect(url: String, options: NSObject) -> Void {
print(url, options, self.connceted);
let handlers = MyEventHandler()
guard let url = URL(string: url) else {
fatalError("Invalid URL")
}
var config = LDSwiftEventSource.EventSource.Config(handler: handlers, url: url);
config.connectionErrorHandler = self.connectionErrorHandler
config.method = "GET"
config.headers = ["Authorization": "REQUIRED TOKEN", "Content-Type": "application/json", "Accept": "text/event-source"]
var instance = LDSwiftEventSource.EventSource(config: config);
instance.start();
self.connceted = true;
print("started instance")
}
@objc(disconnect)
func disconnect() -> Void {
print("disconnected")
}
func connectionErrorHandler(error: Error) -> LDSwiftEventSource.ConnectionErrorAction {
print("RNES error", error)
guard let unsuccessfulResponseError = error as? UnsuccessfulResponseError else { return .proceed }
let responseCode: Int = unsuccessfulResponseError.responseCode
if 204 == responseCode {
return .shutdown
}
return .proceed
}
}
public class MyEventHandler: LDSwiftEventSource.EventHandler {
public func onOpened() {
print("RNES Connection opened")
}
public func onClosed() {
print("RNES Connection closed")
}
public func onMessage(eventType: String, messageEvent: MessageEvent) {
print("RNES Received event of type \(eventType) with data \(messageEvent)")
}
public func onComment(comment: String) {
print("RNES Received comment: \(comment)")
}
public func onError(error: Error) {
print("RNES Error occurred: \(error)")
}
}
Expected behavior
I'm expecting to get any data from server.
I'm mocking local server with express using ngrok to test on real device.
But I can't get any request from client on my server console.
I'm using same server code and works fine on browser & android.
Logs
Here's my logs.
Library version
"LDSwiftEventSource": "3.1.1"
XCode and Swift version
XCode 14.3.1, Swift 5.8.1
Platform the issue occurs on
Testing on iPhone real device & iPhone simulator.
Describe the bug
Hello thanks for great library 🙌. I'm trying to build wrapper library using LDSwiftEventSource internally on my react-native app. However, I'm having problem with getting any events from server.
Logs are attached as screen shots below.
My questions are
To reproduce Here's my minimal code
Expected behavior I'm expecting to get any data from server. I'm mocking local server with express using ngrok to test on real device. But I can't get any request from client on my server console. I'm using same server code and works fine on browser & android.
Logs
Here's my logs.
Library version "LDSwiftEventSource": "3.1.1"
XCode and Swift version XCode 14.3.1, Swift 5.8.1
Platform the issue occurs on Testing on iPhone real device & iPhone simulator.