-
Notifications
You must be signed in to change notification settings - Fork 19
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
Question: Is there a sample code to know how to use this library? #91
Comments
Currently no, just the API reference. Like all of the LaunchDarkly SSE implementations, this library exists because it's needed by other LaunchDarkly projects (https://launchdarkly.github.io/dotnet-server-sdk/, https://launchdarkly.github.io/dotnet-client-sdk/), so even though it can definitely be used for other purposes, we haven't focused on building out its own documentation. I can write you a couple of examples right here, though. |
Basically, any application that wants to use this to read an SSE stream needs to do the following things, at a minimum:
var eventSource = new EventSource(new Uri("https://my-stream-server.com/whatever-uri-path")); Or if you need other configuration: var builder = Configuration.Builder(new Uri("https://my-stream-server.com/whatever-uri-path"))
.RequestHeader("some-header-name", "header-value") // or whatever other options you want
.Build();
var eventSource = new EventSource(builder.Build());
eventSource.MessageReceived += (sender, eventArgs) => {
var eventName = eventArgs.Message.Name;
var eventData = eventArgs.Message.Data;
// do whatever you want to do with the message
}
Task.Run(() => eventSource.StartAsync()); |
I hope that's helpful. |
Thanks a lot @eli-darkly . That's what I wanted. |
How to implement the failure to restart when the link is broken? |
No description provided.
The text was updated successfully, but these errors were encountered: