1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00

update to alpha2

This commit is contained in:
Nikolay Kim 2019-03-30 09:12:42 -07:00
parent 26f7c40d5e
commit 9a80911b92
40 changed files with 106 additions and 147 deletions

View File

@ -21,18 +21,18 @@ members = [
"protobuf", "protobuf",
"r2d2", "r2d2",
"redis-session", "redis-session",
"simple-auth-server", "rustls",
#"simple-auth-server",
"state", "state",
"static_index", "static_index",
"template_askama", "template_askama",
"template_tera", "template_tera",
"template_yarte", "template_yarte",
"tls", "tls",
"rustls", #"unix-socket",
"unix-socket",
"web-cors/backend", "web-cors/backend",
"websocket", "websocket",
"websocket-chat", "websocket-chat",
"websocket-chat-broker", #"websocket-chat-broker",
"websocket-tcp-chat", "websocket-tcp-chat",
] ]

View File

@ -7,7 +7,7 @@ workspace = ".."
[dependencies] [dependencies]
actix = "0.8.0-alpha.2" actix = "0.8.0-alpha.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-redis = { git="https://github.com/actix/actix-redis.git" } actix-redis = { git="https://github.com/actix/actix-redis.git" }
futures = "0.1.23" futures = "0.1.23"
redis-async = "0.4.0" redis-async = "0.4.0"

View File

@ -6,9 +6,9 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
actix-session = "0.1.0-alpha.1" actix-session = "0.1.0-alpha.2"
dotenv = "0.13.0" dotenv = "0.13.0"
env_logger = "0.5.10" env_logger = "0.5.10"
futures = "0.1.22" futures = "0.1.22"

View File

@ -7,7 +7,7 @@ workspace = ".."
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
dotenv = "0.10" dotenv = "0.10"
env_logger = "0.5" env_logger = "0.5"

View File

@ -7,7 +7,7 @@ workspace = ".."
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = { version="1.0.0-alpha.1", features=["ssl"] } actix-web = { version="1.0.0-alpha.2", features=["ssl"] }
futures = "0.1" futures = "0.1"
serde = "1.0.43" serde = "1.0.43"

View File

@ -7,9 +7,9 @@ edition = "2018"
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
actix-session = "0.1.0-alpha.1" actix-session = "0.1.0-alpha.2"
futures = "0.1.25" futures = "0.1.25"
env_logger = "0.5" env_logger = "0.5"

View File

@ -6,5 +6,5 @@ edition = "2018"
workspace = ".." workspace = ".."
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.6" env_logger = "0.6"

View File

@ -6,8 +6,8 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-session = "0.1.0-alpha.1" actix-session = "0.1.0-alpha.2"
futures = "0.1" futures = "0.1"
time = "0.1" time = "0.1"

View File

@ -6,7 +6,7 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
bytes = "0.4" bytes = "0.4"
env_logger = "0.6" env_logger = "0.6"

View File

@ -6,7 +6,7 @@ edition = "2018"
workspace = ".." workspace = ".."
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
derive_more = "0.14.0" derive_more = "0.14.0"
futures = "0.1.23" futures = "0.1.23"

View File

@ -6,7 +6,7 @@ edition = "2018"
workspace = ".." workspace = ".."
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"

View File

@ -6,5 +6,5 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.6" env_logger = "0.6"

View File

@ -7,7 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
clap = "2.32.0" clap = "2.32.0"
futures = "0.1.25" futures = "0.1.25"

View File

@ -15,7 +15,7 @@ path = "src/server.rs"
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.5" env_logger = "0.5"
futures = "0.1" futures = "0.1"

View File

@ -6,7 +6,7 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
bytes = "0.4" bytes = "0.4"
futures = "0.1" futures = "0.1"

View File

@ -6,7 +6,7 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.6" env_logger = "0.6"
futures = "0.1" futures = "0.1"
serde = "1.0" serde = "1.0"

View File

@ -7,6 +7,6 @@ workspace = ".."
[dependencies] [dependencies]
actix-service = "0.3.3" actix-service = "0.3.3"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
futures = "0.1.25" futures = "0.1.25"
env_logger = "0.6" env_logger = "0.6"

View File

@ -10,8 +10,7 @@ name = "multipart"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
#actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-web = { git="https://github.com/actix/actix-web.git" }
env_logger = "0.6" env_logger = "0.6"
futures = "0.1.25" futures = "0.1.25"

View File

@ -2,16 +2,15 @@
name = "protobuf-example" name = "protobuf-example"
version = "0.1.0" version = "0.1.0"
authors = ["kingxsp <jin_hb_zh@126.com>"] authors = ["kingxsp <jin_hb_zh@126.com>"]
workspace = "../" workspace = ".."
edition = "2018"
[dependencies] [dependencies]
bytes = "0.4" bytes = "0.4"
futures = "0.1" futures = "0.1"
failure = "0.1" env_logger = "0.6"
env_logger = "*" derive_more = "0.14"
prost = "0.2.0" prost = "0.2.0"
prost-derive = "0.2.0" prost-derive = "0.2.0"
actix = "0.7" actix-web = "1.0.0-alpha.2"
actix-web = "0.7"

View File

@ -1,19 +1,8 @@
extern crate actix;
extern crate actix_web;
extern crate bytes;
extern crate futures;
#[macro_use]
extern crate failure;
extern crate env_logger;
extern crate prost;
#[macro_use] #[macro_use]
extern crate prost_derive; extern crate prost_derive;
use actix_web::{ use actix_web::{middleware, web, App, Error, HttpResponse, HttpServer};
http, middleware, server, App, AsyncResponder, Error, HttpRequest, HttpResponse,
};
use futures::Future; use futures::Future;
mod protobuf; mod protobuf;
use protobuf::ProtoBufResponseBuilder; use protobuf::ProtoBufResponseBuilder;
@ -26,31 +15,24 @@ pub struct MyObj {
} }
/// This handler uses `ProtoBufMessage` for loading protobuf object. /// This handler uses `ProtoBufMessage` for loading protobuf object.
fn index(req: &HttpRequest) -> Box<Future<Item = HttpResponse, Error = Error>> { fn index(pl: web::Payload) -> impl Future<Item = HttpResponse, Error = Error> {
protobuf::ProtoBufMessage::new(req) protobuf::ProtoBufMessage::new(pl)
.from_err() // convert all errors into `Error` .from_err() // convert all errors into `Error`
.and_then(|val: MyObj| { .and_then(|val: MyObj| {
println!("model: {:?}", val); println!("model: {:?}", val);
Ok(HttpResponse::Ok().protobuf(val)?) // <- send response Ok(HttpResponse::Ok().protobuf(val)?) // <- send response
}) })
.responder()
} }
fn main() { fn main() -> std::io::Result<()> {
::std::env::set_var("RUST_LOG", "actix_web=info"); std::env::set_var("RUST_LOG", "actix_web=info,actix_server=info");
env_logger::init(); env_logger::init();
let sys = actix::System::new("protobuf-example");
server::new(|| { HttpServer::new(|| {
App::new() App::new()
.middleware(middleware::Logger::default()) .wrap(middleware::Logger::default())
.resource("/", |r| r.method(http::Method::POST).f(index)) .service(web::resource("/").route(web::post().to_async(index)))
}) })
.bind("127.0.0.1:8080") .bind("127.0.0.1:8080")?
.unwrap() .run()
.shutdown_timeout(1)
.start();
println!("Started http server: 127.0.0.1:8080");
let _ = sys.run();
} }

View File

@ -1,7 +1,8 @@
use bytes::BytesMut; use bytes::BytesMut;
use futures::{Future, Poll, Stream}; use futures::{Future, Poll, Stream};
use bytes::IntoBuf; use bytes::{Bytes, IntoBuf};
use derive_more::{Display, From};
use prost::DecodeError as ProtoBufDecodeError; use prost::DecodeError as ProtoBufDecodeError;
use prost::EncodeError as ProtoBufEncodeError; use prost::EncodeError as ProtoBufEncodeError;
use prost::Message; use prost::Message;
@ -9,25 +10,25 @@ use prost::Message;
use actix_web::dev::HttpResponseBuilder; use actix_web::dev::HttpResponseBuilder;
use actix_web::error::{Error, PayloadError, ResponseError}; use actix_web::error::{Error, PayloadError, ResponseError};
use actix_web::http::header::CONTENT_TYPE; use actix_web::http::header::CONTENT_TYPE;
use actix_web::{HttpMessage, HttpRequest, HttpResponse, Responder}; use actix_web::{HttpRequest, HttpResponse, Responder};
#[derive(Fail, Debug)] #[derive(Debug, Display, From)]
pub enum ProtoBufPayloadError { pub enum ProtoBufPayloadError {
/// Payload size is bigger than 256k /// Payload size is bigger than 256k
#[fail(display = "Payload size is bigger than 256k")] #[display(fmt = "Payload size is bigger than 256k")]
Overflow, Overflow,
/// Content type error /// Content type error
#[fail(display = "Content type error")] #[display(fmt = "Content type error")]
ContentType, ContentType,
/// Serialize error /// Serialize error
#[fail(display = "ProtoBud serialize error: {}", _0)] #[display(fmt = "ProtoBud serialize error: {}", _0)]
Serialize(#[cause] ProtoBufEncodeError), Serialize(ProtoBufEncodeError),
/// Deserialize error /// Deserialize error
#[fail(display = "ProtoBud deserialize error: {}", _0)] #[display(fmt = "ProtoBud deserialize error: {}", _0)]
Deserialize(#[cause] ProtoBufDecodeError), Deserialize(ProtoBufDecodeError),
/// Payload error /// Payload error
#[fail(display = "Error that occur during reading payload: {}", _0)] #[display(fmt = "Error that occur during reading payload: {}", _0)]
Payload(#[cause] PayloadError), Payload(PayloadError),
} }
impl ResponseError for ProtoBufPayloadError { impl ResponseError for ProtoBufPayloadError {
@ -39,26 +40,14 @@ impl ResponseError for ProtoBufPayloadError {
} }
} }
impl From<PayloadError> for ProtoBufPayloadError {
fn from(err: PayloadError) -> ProtoBufPayloadError {
ProtoBufPayloadError::Payload(err)
}
}
impl From<ProtoBufDecodeError> for ProtoBufPayloadError {
fn from(err: ProtoBufDecodeError) -> ProtoBufPayloadError {
ProtoBufPayloadError::Deserialize(err)
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct ProtoBuf<T: Message>(pub T); pub struct ProtoBuf<T: Message>(pub T);
impl<T: Message> Responder for ProtoBuf<T> { impl<T: Message> Responder for ProtoBuf<T> {
type Item = HttpResponse;
type Error = Error; type Error = Error;
type Future = Result<HttpResponse, Error>;
fn respond_to<S>(self, _: &HttpRequest<S>) -> Result<HttpResponse, Error> { fn respond_to(self, _: &HttpRequest) -> Result<HttpResponse, Error> {
let mut buf = Vec::new(); let mut buf = Vec::new();
self.0 self.0
.encode(&mut buf) .encode(&mut buf)
@ -78,9 +67,11 @@ pub struct ProtoBufMessage<U: Message + Default> {
impl<U: Message + Default + 'static> ProtoBufMessage<U> { impl<U: Message + Default + 'static> ProtoBufMessage<U> {
/// Create `ProtoBufMessage` for request. /// Create `ProtoBufMessage` for request.
pub fn new(req: &HttpRequest) -> Self { pub fn new<S>(pl: S) -> Self
let fut = req where
.payload() S: Stream<Item = Bytes, Error = PayloadError> + 'static,
{
let fut = pl
.map_err(|e| ProtoBufPayloadError::Payload(e)) .map_err(|e| ProtoBufPayloadError::Payload(e))
.fold(BytesMut::new(), move |mut body, chunk| { .fold(BytesMut::new(), move |mut body, chunk| {
body.extend_from_slice(&chunk); body.extend_from_slice(&chunk);

View File

@ -7,7 +7,7 @@ workspace = ".."
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
futures = "0.1" futures = "0.1"
env_logger = "0.6" env_logger = "0.6"

View File

@ -7,7 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
actix = "0.8.0-alpha.2" actix = "0.8.0-alpha.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-session = "0.1.0-alpha.1" actix-session = "0.1.0-alpha.2"
actix-redis = { git = "https://github.com/actix/actix-redis.git", features = ["web"] } actix-redis = { git = "https://github.com/actix/actix-redis.git", features = ["web"] }
env_logger = "0.6" env_logger = "0.6"

View File

@ -2,7 +2,8 @@
name = "rustls-example" name = "rustls-example"
version = "0.1.0" version = "0.1.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
workspace = "../" workspace = ".."
edition = "2018"
[[bin]] [[bin]]
name = "rustls-server" name = "rustls-server"
@ -10,6 +11,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
env_logger = "0.5" env_logger = "0.5"
rustls = "0.14" rustls = "0.15"
actix = "0.7" actix-web = { version = "1.0.0-alpha.2", features=["rust-tls"] }
actix-web = { version = "0.7", features=["rust-tls"] } actix-files = "0.1.0-alpha.1"

View File

@ -1,32 +1,24 @@
extern crate actix;
extern crate actix_web;
extern crate env_logger;
extern crate rustls;
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use actix_web::{http, middleware, server, App, Error, HttpRequest, HttpResponse}; use actix_files::Files;
use actix_web::{middleware, web, App, Error, HttpRequest, HttpResponse, HttpServer};
use rustls::internal::pemfile::{certs, rsa_private_keys}; use rustls::internal::pemfile::{certs, rsa_private_keys};
use rustls::{NoClientAuth, ServerConfig}; use rustls::{NoClientAuth, ServerConfig};
use server::ServerFlags;
use actix_web::fs::StaticFiles;
/// simple handle /// simple handle
fn index(req: &HttpRequest) -> Result<HttpResponse, Error> { fn index(req: HttpRequest) -> Result<HttpResponse, Error> {
println!("{:?}", req); println!("{:?}", req);
Ok(HttpResponse::Ok() Ok(HttpResponse::Ok()
.content_type("text/plain") .content_type("text/plain")
.body("Welcome!")) .body("Welcome!"))
} }
fn main() { fn main() -> std::io::Result<()> {
if ::std::env::var("RUST_LOG").is_err() { if std::env::var("RUST_LOG").is_err() {
::std::env::set_var("RUST_LOG", "actix_web=info"); std::env::set_var("RUST_LOG", "actix_web=info");
} }
env_logger::init(); env_logger::init();
let sys = actix::System::new("ws-example");
// load ssl keys // load ssl keys
let mut config = ServerConfig::new(NoClientAuth::new()); let mut config = ServerConfig::new(NoClientAuth::new());
@ -36,32 +28,20 @@ fn main() {
let mut keys = rsa_private_keys(key_file).unwrap(); let mut keys = rsa_private_keys(key_file).unwrap();
config.set_single_cert(cert_chain, keys.remove(0)).unwrap(); config.set_single_cert(cert_chain, keys.remove(0)).unwrap();
// actix acceptor HttpServer::new(|| {
let acceptor = server::RustlsAcceptor::with_flags(
config,
ServerFlags::HTTP1 | ServerFlags::HTTP2,
);
server::new(|| {
App::new() App::new()
// enable logger // enable logger
.middleware(middleware::Logger::default()) .wrap(middleware::Logger::default())
// register simple handler, handle all methods // register simple handler, handle all methods
.resource("/index.html", |r| r.f(index)) .service(web::resource("/index.html").to(index))
// with path parameters // with path parameters
.resource("/", |r| { .service(web::resource("/").route(web::get().to(|| {
r.method(http::Method::GET).f(|_| {
HttpResponse::Found() HttpResponse::Found()
.header("LOCATION", "/index.html") .header("LOCATION", "/index.html")
.finish() .finish()
})))
.service(Files::new("/static", "static"))
}) })
}) .bind_rustls("127.0.0.1:8443", config)?
.handler("/static", StaticFiles::new("static").unwrap()) .run()
})
.bind_with("127.0.0.1:8443", move || acceptor.clone())
.unwrap()
.start();
println!("Started http server: 127.0.0.1:8443");
let _ = sys.run();
} }

View File

@ -7,7 +7,8 @@ workspace = ".."
[dependencies] [dependencies]
actix = { version = "0.8.0-alpha.2", features = ["http"] } actix = { version = "0.8.0-alpha.2", features = ["http"] }
actix-web = "1.0.0-alpha.1" actix-rt = "0.2.2"
actix-web = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
bcrypt = "0.2.1" bcrypt = "0.2.1"

View File

@ -37,6 +37,7 @@ fn main() -> std::io::Result<()> {
"simple-auth-server=debug,actix_web=info,actix_server=info", "simple-auth-server=debug,actix_web=info,actix_server=info",
); );
env_logger::init(); env_logger::init();
let sys = actix_rt::System::new("example");
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
@ -93,5 +94,7 @@ fn main() -> std::io::Result<()> {
.service(fs::Files::new("/", "./static/").index_file("index.html")) .service(fs::Files::new("/", "./static/").index_file("index.html"))
}) })
.bind("127.0.0.1:3000")? .bind("127.0.0.1:3000")?
.run() .start();
sys.run()
} }

View File

@ -6,6 +6,6 @@ workspace = ".."
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
futures = "0.1.25" futures = "0.1.25"
env_logger = "0.6" env_logger = "0.6"

View File

@ -9,5 +9,5 @@ edition = "2018"
futures = "0.1" futures = "0.1"
env_logger = "0.5" env_logger = "0.5"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"

View File

@ -7,7 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
#askama = { version = "0.8", features = ["with-actix-web"] } #askama = { version = "0.8", features = ["with-actix-web"] }
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.6" env_logger = "0.6"
askama = "0.8" askama = "0.8"

View File

@ -8,4 +8,4 @@ edition = "2018"
[dependencies] [dependencies]
env_logger = "0.6" env_logger = "0.6"
tera = "0.11" tera = "0.11"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"

View File

@ -7,7 +7,7 @@ edition = "2018"
workspace = ".." workspace = ".."
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
env_logger = "0.6" env_logger = "0.6"
yarte = "0.1" yarte = "0.1"

View File

@ -11,6 +11,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
actix-rt = "0.2" actix-rt = "0.2"
actix-web = { version="1.0.0-alpha.1", features=["ssl"] } actix-web = { version="1.0.0-alpha.2", features=["ssl"] }
env_logger = "0.6" env_logger = "0.6"
openssl = { version="0.10" } openssl = { version="0.10" }

View File

@ -6,7 +6,7 @@ workspace = "../../"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"

View File

@ -11,8 +11,8 @@ path = "src/main.rs"
[dependencies] [dependencies]
actix = "0.8.0-alpha.2" actix = "0.8.0-alpha.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-web-actors = "1.0.0-alpha.1" actix-web-actors = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
rand = "0.6" rand = "0.6"

View File

@ -173,6 +173,7 @@ impl StreamHandler<ws::Message, ws::ProtocolError> for WsChatSession {
ws::Message::Close(_) => { ws::Message::Close(_) => {
ctx.stop(); ctx.stop();
} }
ws::Message::Nop => (),
} }
} }
} }

View File

@ -15,8 +15,8 @@ path = "src/client.rs"
[dependencies] [dependencies]
actix = "0.8.0-alpha.2" actix = "0.8.0-alpha.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-web-actors = "1.0.0-alpha.1" actix-web-actors = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
rand = "0.6" rand = "0.6"

View File

@ -180,6 +180,7 @@ impl StreamHandler<ws::Message, ws::ProtocolError> for WsChatSession {
ws::Message::Close(_) => { ws::Message::Close(_) => {
ctx.stop(); ctx.stop();
} }
ws::Message::Nop => (),
} }
} }
} }

View File

@ -14,9 +14,9 @@ path = "src/main.rs"
#path = "src/client.rs" #path = "src/client.rs"
[dependencies] [dependencies]
actix = "0.8.0-alpha.1" actix = "0.8.0-alpha.2"
actix-web = "1.0.0-alpha.1" actix-web = "1.0.0-alpha.2"
actix-web-actors = "1.0.0-alpha.1" actix-web-actors = "1.0.0-alpha.2"
actix-files = "0.1.0-alpha.1" actix-files = "0.1.0-alpha.1"
env_logger = "0.6" env_logger = "0.6"
futures = "0.1" futures = "0.1"

View File

@ -58,6 +58,7 @@ impl StreamHandler<ws::Message, ws::ProtocolError> for MyWebSocket {
ws::Message::Close(_) => { ws::Message::Close(_) => {
ctx.stop(); ctx.stop();
} }
ws::Message::Nop => (),
} }
} }
} }