Skip to content

Commit

Permalink
Fix references to heartbeat_thread_communicator
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Nov 19, 2023
1 parent 0640144 commit 5a9a0d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ where
op_code: Some(GATEWAY_HEARTBEAT),
};

let heartbeat_thread_communicator = self.get_heartbeat_handler().send;
let heartbeat_thread_communicator = &self.get_heartbeat_handler().send;

heartbeat_thread_communicator
.send(heartbeat_communication)
Expand Down Expand Up @@ -409,7 +409,7 @@ where
};

let heartbeat_handler = self.get_heartbeat_handler();
let heartbeat_thread_communicator = heartbeat_handler.send;
let heartbeat_thread_communicator = &heartbeat_handler.send;

heartbeat_thread_communicator
.send(heartbeat_communication)
Expand Down Expand Up @@ -442,7 +442,7 @@ where
};

let heartbeat_handler = self.get_heartbeat_handler();
let heartbeat_thread_communicator = heartbeat_handler.send;
let heartbeat_thread_communicator = &heartbeat_handler.send;
heartbeat_thread_communicator
.send(heartbeat_communication)
.await
Expand Down Expand Up @@ -571,7 +571,7 @@ pub struct HeartbeatHandler<T: MessageCapable + Send + 'static, S: Sink<T>> {
hb_type: (PhantomData<T>, PhantomData<S>),
}

impl<T: MessageCapable + Send + 'static, S: Sink<T> + Send> HeartbeatHandler<T, S> {
impl<T: MessageCapable + Send + 'static, S: Sink<T> + Send + 'static> HeartbeatHandler<T, S> {
pub async fn heartbeat_task(
websocket_tx: Arc<Mutex<SplitSink<S, T>>>,
heartbeat_interval: Duration,
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/wasm/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl GatewayCapable<WsMessage, WsStream> for WasmGateway {
async fn spawn<G: GatewayHandleCapable<WsMessage, WsStream>>(
websocket_url: String,
) -> Result<G, GatewayError> {
let (_, mut websocket_stream) = match WsMeta::connect(websocket_url.clone(), None).await {
let (_, websocket_stream) = match WsMeta::connect(websocket_url.clone(), None).await {
Ok(ws) => Ok(ws),
Err(e) => Err(GatewayError::CannotConnect {
error: e.to_string(),
Expand Down
18 changes: 17 additions & 1 deletion src/gateway/wasm/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct WasmGatewayHandle {
pub(crate) store: GatewayStore,
}

#[async_trait]
#[async_trait(?Send)]
impl GatewayHandleCapable<WsMessage, WsStream> for WasmGatewayHandle {
fn new(
url: String,
Expand All @@ -31,4 +31,20 @@ impl GatewayHandleCapable<WsMessage, WsStream> for WasmGatewayHandle {
store,
}
}

async fn send_json_event(&self, op_code: u8, to_send: serde_json::Value) {
self.send_json_event(op_code, to_send).await
}

async fn observe<U: Updateable + Clone + std::fmt::Debug + Composite<U> + Send + Sync>(
&self,
object: Arc<RwLock<U>>,
) -> Arc<RwLock<U>> {
self.observe(object).await
}

async fn close(&self) {
self.kill_send.send(()).unwrap();
self.websocket_send.lock().await.close().await.unwrap();
}
}

0 comments on commit 5a9a0d1

Please sign in to comment.