Skip to content
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

Socket Extensions + various fixs + docs #13

Merged
merged 13 commits into from
Jun 13, 2023
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 2 additions & 33 deletions engineioxide/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,6 @@ pub struct EngineIoConfig {
/// The maximum number of packets that can be buffered per connection before being emitted to the client.
///
/// If the buffer if full the `emit()` method will return an error
/// ```
/// use engineioxide::{
/// layer::{EngineIoHandler, EngineIoLayer},
/// socket::Socket,
/// };
/// use std::sync::Arc;
/// #[derive(Clone)]
/// struct MyHandler;
///
/// #[engineioxide::async_trait]
/// impl EngineIoHandler for MyHandler {
///
/// type Data = ();
/// fn on_connect(self: Arc<Self>, socket: &Socket<Self>) {
/// println!("socket connect {}", socket.sid);
/// }
/// fn on_disconnect(self: Arc<Self>, socket: &Socket<Self>) {
/// println!("socket disconnect {}", socket.sid);
/// }
///
/// async fn on_message(self: Arc<Self>, msg: String, socket: &Socket<Self>) {
/// println!("Ping pong message {:?}", msg);
/// socket.emit(msg).unwrap();
/// }
///
/// async fn on_binary(self: Arc<Self>, data: Vec<u8>, socket: &Socket<Self>) {
/// println!("Ping pong binary message {:?}", data);
/// socket.emit_binary(data).unwrap();
/// }
/// }
/// ```
pub max_buffer_size: usize,

/// The maximum number of bytes that can be received per http request.
Expand Down Expand Up @@ -131,11 +100,11 @@ impl EngineIoConfigBuilder {
///
/// If the buffer if full the `emit()` method will return an error
/// ```
/// use engineioxide::{
/// # use engineioxide::{
/// layer::{EngineIoHandler, EngineIoLayer},
/// socket::Socket,
/// };
/// use std::sync::Arc;
/// # use std::sync::Arc;
/// #[derive(Clone)]
/// struct MyHandler;
///
Expand Down
3 changes: 2 additions & 1 deletion socketioxide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ tower-http = "0.4.0"
tracing = "0.1.37"
thiserror = "1.0.40"
itertools = "0.10.5"
dashmap = "5.4.0"

[dev-dependencies]
axum = "0.6.18"
tracing-subscriber = "0.3.17"
tracing-subscriber = "0.3.17"
8 changes: 5 additions & 3 deletions socketioxide/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ impl<A: Adapter> EngineIoHandler for Client<A> {
type Data = SocketData;

fn on_connect(self: Arc<Self>, socket: &EIoSocket<Self>) {
println!("socket connect {}", socket.sid);
// self.state = SocketState::AwaitingConnect;
debug!("eio socket connect {}", socket.sid);
}
fn on_disconnect(self: Arc<Self>, socket: &EIoSocket<Self>) {
println!("socket disconnect {}", socket.sid);
debug!("eio socket disconnect {}", socket.sid);
self.ns.values().for_each(|ns| {
ns.disconnect(socket.sid).ok();
});
}

async fn on_message(self: Arc<Self>, msg: String, socket: &EIoSocket<Self>) {
Expand Down
Loading