hathora-client-sdk

Crates.iohathora-client-sdk
lib.rshathora-client-sdk
version0.6.0
sourcesrc
created_at2022-10-26 16:10:28.558347
updated_at2022-11-15 14:52:34.180108
descriptionUtilities for building a Hathora client
homepage
repository
max_upload_size
id698017
size8,616
Harsh Pandey (hpx7)

documentation

README

Hathora Rust Client SDK

crate version

See this client in action here: https://github.com/hathora/topdown-shooter-bevy-client

Usage

let app_id = "...".to_string();
let client = HathoraClient::new(app_id, None);
let token = client
    .login_anonymous()
    .expect("Logging in should succeed.");
let roomId = client
    .create(&token, vec![])
    .expect("Creating a room should succeed");
let mut transport = client
    .connect(&token, &roomId, HathoraTransportType::WebSocket)
    .expect("Creating a websocket should succeed.");

let message = transport
    .read_message()
    .expect("Reading from websocket should succeed");
println!("Got message: {:?}", message);
transport
    .write_message(b"{ message: \"Hello world\" }".to_vec())
    .expect("Writing to socket should suceed");

Publishing

cargo publish
Commit count: 0

cargo fmt