Skip to content

Commit 12da424

Browse files
committed
feat: add start_connected method
Add a start_connected method for better error handling and ergononics when only one connection is expected. Fixes #293
1 parent 7ca128d commit 12da424

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/asynchronous/server.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ 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().await
184+
}
185+
174186
pub async fn shutdown(&mut self) -> Result<()> {
175187
self.stop_listen().await;
176188
self.disconnect().await;

0 commit comments

Comments
 (0)