1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

update actix api

This commit is contained in:
Nikolay Kim
2018-02-12 01:13:06 -08:00
parent 285c66e7d8
commit 30bdf9cb5e
6 changed files with 33 additions and 38 deletions

View File

@ -103,7 +103,7 @@ pub struct WsClient {
http_err: Option<HttpError>,
origin: Option<HeaderValue>,
protocols: Option<String>,
conn: Address<ClientConnector>,
conn: Addr<Unsync<ClientConnector>>,
}
impl WsClient {
@ -114,7 +114,7 @@ impl WsClient {
}
/// Create new websocket connection with custom `ClientConnector`
pub fn with_connector<S: AsRef<str>>(uri: S, conn: Address<ClientConnector>) -> WsClient {
pub fn with_connector<S: AsRef<str>>(uri: S, conn: Addr<Unsync<ClientConnector>>) -> WsClient {
let mut cl = WsClient {
request: ClientRequest::build(),
err: None,

View File

@ -5,9 +5,9 @@ use futures::unsync::oneshot;
use smallvec::SmallVec;
use actix::{Actor, ActorState, ActorContext, AsyncContext,
Address, SyncAddress, Handler, ResponseType, SpawnHandle, MessageResult};
Addr, Handler, ResponseType, SpawnHandle, MessageResult, Syn, Unsync};
use actix::fut::ActorFuture;
use actix::dev::{ContextImpl, Envelope, ToEnvelope, RemoteEnvelope};
use actix::dev::{ContextImpl, ToEnvelope, RemoteEnvelope};
use body::{Body, Binary};
use error::{Error, ErrorInternalServerError};
@ -67,13 +67,13 @@ impl<A, S> AsyncContext<A> for WebsocketContext<A, S> where A: Actor<Context=Sel
#[doc(hidden)]
#[inline]
fn local_address(&mut self) -> Address<A> {
fn unsync_address(&mut self) -> Addr<Unsync<A>> {
self.inner.unsync_address()
}
#[doc(hidden)]
#[inline]
fn sync_address(&mut self) -> SyncAddress<A> {
fn sync_address(&mut self) -> Addr<Syn<A>> {
self.inner.sync_address()
}
}
@ -217,14 +217,12 @@ impl<A, S> ActorHttpContext for WebsocketContext<A, S> where A: Actor<Context=Se
}
}
impl<A, S> ToEnvelope<A> for WebsocketContext<A, S>
where A: Actor<Context=WebsocketContext<A, S>>,
impl<A, M, S> ToEnvelope<Syn<A>, M> for WebsocketContext<A, S>
where A: Actor<Context=WebsocketContext<A, S>> + Handler<M>,
M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send,
{
#[inline]
fn pack<M>(msg: M, tx: Option<Sender<MessageResult<M>>>) -> Envelope<A>
where A: Handler<M>,
M: ResponseType + Send + 'static, M::Item: Send, M::Error: Send {
RemoteEnvelope::envelope(msg, tx).into()
fn pack(msg: M, tx: Option<Sender<MessageResult<M>>>) -> Syn<A> {
Syn::new(Box::new(RemoteEnvelope::envelope(msg, tx)))
}
}