1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-12-18 01:33:59 +01:00

update websocket example

This commit is contained in:
Nikolay Kim 2018-01-01 09:31:42 -08:00
parent e798af26a2
commit 284b59722a
2 changed files with 7 additions and 3 deletions

View File

@ -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",
] ]

View File

@ -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()));
} }