MCPcopy Create free account
hub / github.com/Botloader/botloader / run

Method run

components/webapi/src/routes/ws.rs:53–93  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

51 }
52
53 async fn run(&mut self) {
54 let mut ping_ticker = tokio::time::interval(Duration::from_secs(30));
55
56 loop {
57 // SelectAll returns Ready(None) when empty
58 // so if we didn't have this check this thread
59 // would get pinned at 100%
60 if !self.active_log_streams.is_empty() {
61 tokio::select! {
62 item = self.active_log_streams.next() => {
63 if !self.handle_log_stream_item(item).await {
64 return;
65 }
66 },
67 ws = self.socket.recv() => {
68 if !self.handle_ws_rcv(ws).await {
69 return;
70 }
71 },
72 _ = ping_ticker.tick() => {
73 if !self.send_ping().await{
74 return;
75 }
76 },
77 }
78 } else {
79 tokio::select! {
80 ws = self.socket.recv() => {
81 if !self.handle_ws_rcv(ws).await {
82 return;
83 }
84 },
85 _ = ping_ticker.tick() => {
86 if !self.send_ping().await{
87 return;
88 }
89 },
90 }
91 }
92 }
93 }
94
95 async fn handle_log_stream_item(&mut self, item: Option<Result<LogEntry, SseError>>) -> bool {
96 match item {

Callers 6

handle_socket_upgradeFunction · 0.45
bl_admin_only_mwFunction · 0.45
plugin_middlewareFunction · 0.45
session_mwFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected