Skip to content

Websocket-based client for Phoenix channels

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

wanderers-nft/phyllo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phyllo

Phoenix channels in Rust. This crate uses the Actor model to provide Socket and Channel abstractions for connecting to, receiving and sending messages in a topical fashion. The overall structure is based on the reference JavaScript client.

Example

Warning: the results returned may include NSFW links or comments.

use serde_json::Value;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // The socket is generic over a Topic.
    let mut socket = SocketBuilder::new(Url::parse("wss://furbooru.org/socket/websocket")?)
        .build::<String>()
        .await;

    // Each channel is generic over an Event and Payload type.
    // For simplicity we use serde_json::Value, but in your own code you should deserialize
    // to something strongly-typed.
    let (_channel, mut subscription) = socket
        .channel::<String, Value, Value>(ChannelBuilder::new("firehose".to_string()))
        .await?;

    loop {
        let v = subscription.recv().await?;
        println!("{:?}", v);
    }
}

Features

TLS is not enabled by default. Enable either of the following for TLS support:

License: MIT OR Apache-2.0

About

Websocket-based client for Phoenix channels

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages