1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-30 03:44:27 +02:00

new StreamHandler impl

This commit is contained in:
Nikolay Kim
2018-06-09 07:53:46 -07:00
parent 9151d61eda
commit 818d0bc187
4 changed files with 49 additions and 32 deletions

View File

@ -4,8 +4,8 @@ use std::time::Duration;
use std::{io, net, thread};
use actix::{
fut, msgs, signal, Actor, ActorFuture, Addr, Arbiter, AsyncContext, Context,
ContextFutureSpawner, Handler, Response, StreamHandler, System, WrapFuture,
fut, msgs, signal, Actor, ActorContext, ActorFuture, Addr, Arbiter, AsyncContext,
Context, ContextFutureSpawner, Handler, Response, StreamHandler, System, WrapFuture,
};
use futures::sync::mpsc;
@ -626,10 +626,11 @@ impl<H: IntoHttpHandler> Handler<signal::Signal> for HttpServer<H> {
/// Commands from accept threads
impl<H: IntoHttpHandler> StreamHandler<ServerCommand, ()> for HttpServer<H> {
fn finished(&mut self, _: &mut Context<Self>) {}
fn handle(&mut self, msg: ServerCommand, _: &mut Context<Self>) {
fn handle(
&mut self, msg: Result<Option<ServerCommand>, ()>, ctx: &mut Context<Self>,
) {
match msg {
ServerCommand::WorkerDied(idx, socks) => {
Ok(Some(ServerCommand::WorkerDied(idx, socks))) => {
let mut found = false;
for i in 0..self.workers.len() {
if self.workers[i].0 == idx {
@ -675,6 +676,7 @@ impl<H: IntoHttpHandler> StreamHandler<ServerCommand, ()> for HttpServer<H> {
self.workers.push((new_idx, addr));
}
}
_ => ctx.stop(),
}
}
}