1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 13:29:24 +00: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/template_tera",
"examples/tls",
"examples/websocket",
"examples/websocket-chat",
]

View file

@ -10,10 +10,11 @@ extern crate env_logger;
use actix::*;
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
fn ws_index(r: HttpRequest) -> Result<HttpResponse, Error> {
fn ws_index(r: HttpRequest) -> Result<HttpResponse> {
ws::start(r, MyWebSocket)
}
@ -73,7 +74,9 @@ fn main() {
.bind("127.0.0.1:8080").unwrap()
.start();
if cfg!(target_os = "linux") { // Subscribe to unix signals
// Subscribe to unix signals
#[cfg(unix)]
{
let signals = Arbiter::system_registry().get::<ProcessSignals>();
signals.send(Subscribe(_addr.subscriber()));
}