Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viniciusgerevini/sse-client
EventSource implementation in Rust to handle streams of Server-Sent Events
https://github.com/viniciusgerevini/sse-client
client eventsource sse sse-client stream
Last synced: about 1 month ago
JSON representation
EventSource implementation in Rust to handle streams of Server-Sent Events
- Host: GitHub
- URL: https://github.com/viniciusgerevini/sse-client
- Owner: viniciusgerevini
- License: apache-2.0
- Created: 2018-08-25T23:49:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T06:57:58.000Z (almost 5 years ago)
- Last Synced: 2024-08-08T22:36:38.715Z (5 months ago)
- Topics: client, eventsource, sse, sse-client, stream
- Language: Rust
- Homepage:
- Size: 143 KB
- Stars: 17
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# SSE Client
[![Documentation](https://docs.rs/sse-client/badge.svg)](https://docs.rs/sse-client/) [![Build Status](https://travis-ci.com/viniciusgerevini/sse-client.svg?branch=master)](https://travis-ci.com/viniciusgerevini/sse-client)
EventSource implementation in Rust to handle streams of Server-Sent Events.
It handles connections, redirections, retries and message parsing.To know more about SSE: [Standard](https://html.spec.whatwg.org/multipage/server-sent-events.html) | [EventSource interface](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)
# Example:
Usage:
```rust
extern crate sse_client;
use sse_client::EventSource;let event_source = EventSource::new("http://event-stream-address/sub").unwrap();
event_source.on_message(|message| {
println!("New message event {:?}", message);
});event_source.add_event_listener("error", |error| {
println!("Error {:?}", error);
});```
Or:
```rust
extern crate sse_client;
use sse_client::EventSource;let event_source = EventSource::new("http://event-stream-address/sub").unwrap();
for event in event_source.receiver().iter() {
println!("New Message: {}", event.data);
}
```
## Cargo features* `native-tls` enables support for HTTPS URLs using [native-tls](https://crates.io/crates/native-tls)
* `native-tls-vendored` will additionally link OpenSSL statically## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE))
* MIT license
([LICENSE-MIT](LICENSE-MIT))at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.