Skip to content

Commit 85c5f91

Browse files
committed
add start_connected method
1 parent 7ca128d commit 85c5f91

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/asynchronous/server.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ impl Server {
171171
Ok(())
172172
}
173173

174+
pub async fn start_connected(&mut self, conn: Socket) -> std::io::Result<()> {
175+
let services = self.services.clone();
176+
let shutdown_waiter = self.shutdown.subscribe();
177+
let delegate = ServerBuilder {
178+
services,
179+
streams: Arc::new(Mutex::new(HashMap::new())),
180+
shutdown_waiter,
181+
};
182+
let conn = Connection::new(conn, delegate);
183+
conn.run()
184+
.await
185+
.inspect_err(|e| {
186+
trace!("connection run error. {}", e);
187+
})
188+
}
189+
174190
pub async fn shutdown(&mut self) -> Result<()> {
175191
self.stop_listen().await;
176192
self.disconnect().await;

0 commit comments

Comments
 (0)