mirror of
https://github.com/actix/actix-extras.git
synced 2024-12-18 09:43:11 +01:00
update websocket example
This commit is contained in:
parent
e798af26a2
commit
284b59722a
@ -111,5 +111,6 @@ members = [
|
|||||||
"examples/state",
|
"examples/state",
|
||||||
"examples/template_tera",
|
"examples/template_tera",
|
||||||
"examples/tls",
|
"examples/tls",
|
||||||
|
"examples/websocket",
|
||||||
"examples/websocket-chat",
|
"examples/websocket-chat",
|
||||||
]
|
]
|
||||||
|
@ -10,10 +10,11 @@ extern crate env_logger;
|
|||||||
|
|
||||||
use actix::*;
|
use actix::*;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
#[cfg(target_os = "linux")] use actix::actors::signal::{ProcessSignals, Subscribe};
|
#[cfg(unix)]
|
||||||
|
use actix::actors::signal::{ProcessSignals, Subscribe};
|
||||||
|
|
||||||
/// do websocket handshake and start `MyWebSocket` actor
|
/// do websocket handshake and start `MyWebSocket` actor
|
||||||
fn ws_index(r: HttpRequest) -> Result<HttpResponse, Error> {
|
fn ws_index(r: HttpRequest) -> Result<HttpResponse> {
|
||||||
ws::start(r, MyWebSocket)
|
ws::start(r, MyWebSocket)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +74,9 @@ fn main() {
|
|||||||
.bind("127.0.0.1:8080").unwrap()
|
.bind("127.0.0.1:8080").unwrap()
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
if cfg!(target_os = "linux") { // Subscribe to unix signals
|
// Subscribe to unix signals
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
let signals = Arbiter::system_registry().get::<ProcessSignals>();
|
let signals = Arbiter::system_registry().get::<ProcessSignals>();
|
||||||
signals.send(Subscribe(_addr.subscriber()));
|
signals.send(Subscribe(_addr.subscriber()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user