Popularity
3.0
Stable
Activity
0.0
Declining
61
5
18
Programming language: Rust
License: MIT License
Latest version: v0.4.0
sockjs alternatives and similar packages
Based on the "WebSocket" category.
Alternatively, view sockjs alternatives based on common mentions on social networks and blogs.
-
tungstenite-rs
Lightweight stream-based WebSocket implementation for Rust.
Clean code begins in your IDE with SonarLint
Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.
Promo
www.sonarlint.org
Do you think we are missing an alternative of sockjs or a related project?
README
SockJS server

SockJS server for Actix framework.
- API Documentation
- Cargo package: sockjs
- SockJS is built with Actix web
- Minimum supported Rust version: 1.21 or later
Actix SockJS is licensed under the Apache-2.0 license.
Usage
To use sockjs
, add this to your Cargo.toml
:
[dependencies]
sockjs = "0.2"
Supported transports
- websocket
- xhr-streaming
- xhr-polling
- iframe-xhr-polling
- iframe-eventsource (EventSource used from an iframe via postMessage)
- iframe-htmlfile (HtmlFile used from an iframe via postMessage.)
- jsonp-polling
Simple chat example
extern crate actix;
extern crate actix_web;
extern crate sockjs;
use actix_web::*;
use actix::prelude::*;
use sockjs::{Message, Session, CloseReason, SockJSManager, SockJSContext};
struct Chat;
/// `SockJSContext` context is required for sockjs session
impl Actor for Chat {
type Context = SockJSContext<Self>;
}
/// Session has to implement `Default` trait
impl Default for Chat {
fn default() -> Chat { Chat }
}
/// Sockjs session trait
impl Session for Chat {
fn opened(&mut self, ctx: &mut SockJSContext<Self>) {
ctx.broadcast("Someone joined.")
}
fn closed(&mut self, ctx: &mut SockJSContext<Self>, _: CloseReason) {
ctx.broadcast("Someone left.")
}
}
/// Session has to be able to handle `sockjs::Message` messages
impl Handler<Message> for Chat {
type Result = ();
fn handle(&mut self, msg: Message, ctx: &mut SockJSContext<Self>)
{
// broadcast message to all sessions
ctx.broadcast(msg);
}
}
fn main() {
let sys = actix::System::new("sockjs-chat");
// SockJS sessions manager
let sm: Addr<Syn, _> = SockJSManager::<Chat>::start_default();
HttpServer::new(move || {
let manager = sm.clone();
Application::new()
// register SockJS application
.handler(
"/sockjs/", sockjs::SockJS::new(manager.clone()))})
.bind("127.0.0.1:8080").unwrap()
.start();
// let _ = sys.run();
}
*Note that all licence references and agreements mentioned in the sockjs README section above
are relevant to that project's source code only.