添加个disconnect
This commit is contained in:
parent
7108b337f9
commit
1cf098ccd8
@ -29,6 +29,7 @@ pub struct Cluster {
|
||||
|
||||
impl Cluster {
|
||||
pub async fn new(config: Config) -> Self {
|
||||
|
||||
let disconnect = |reason: Payload, _: Client| {
|
||||
async move {
|
||||
fatal!("socket disconnect: {:?}", reason);
|
||||
@ -48,9 +49,14 @@ impl Cluster {
|
||||
.connect()
|
||||
.await
|
||||
.expect("Failed to connect to center");
|
||||
info!("websocket connected");
|
||||
Self { config, ua, socket }
|
||||
}
|
||||
|
||||
pub async fn disconnect(&self) {
|
||||
self.socket.disconnect().await.expect("Failed to disconnect");
|
||||
}
|
||||
|
||||
/// ```typescript
|
||||
/// this.ua = `openbmclapi-cluster/${version}`
|
||||
/// this.got = got.extend({
|
||||
@ -164,5 +170,6 @@ mod tests {
|
||||
let config = gen_config();
|
||||
let cluster = Cluster::new(config).await;
|
||||
cluster.get_file_list().await.unwrap();
|
||||
cluster.disconnect().await;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user