Fix references to heartbeat_thread_communicator

This commit is contained in:
bitfl0wer 2023-11-19 18:27:49 +01:00
parent 19f8403bcf
commit 0e16e55d64
3 changed files with 22 additions and 6 deletions

View File

@ -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)
@ -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)
@ -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
@ -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,

View File

@ -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(),

View File

@ -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,
@ -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();
}
}