@@ -11,13 +11,27 @@ use std::sync::Arc;
1111use tokio:: sync:: { broadcast, mpsc, Mutex , RwLock } ;
1212use tokio:: task:: JoinHandle ;
1313use tracing:: { error, info, warn} ;
14+ use serde:: Serialize ;
1415
1516use crate :: blacklist:: Blacklist ;
1617use crate :: component:: { CheckpointBroadcastFrame , BridgeToParent , CloseReason , WrappedStorage , WrappedTransport } ;
1718use crate :: frame:: { EventFrame , SignalFrame } ;
1819use crate :: handle:: Handle ;
1920use crate :: utils:: current_timestamp;
2021
22+ #[ derive( Serialize , Clone ) ]
23+ #[ serde( rename_all = "camelCase" ) ]
24+ pub struct ServingGame {
25+ addr : String ,
26+ bundle_addr : String ,
27+ }
28+
29+ impl ServingGame {
30+ pub fn new ( addr : String , bundle_addr : String ) -> Self {
31+ Self { addr, bundle_addr }
32+ }
33+ }
34+
2135pub struct GameManager {
2236 games : Arc < RwLock < HashMap < String , Handle > > > ,
2337}
@@ -30,6 +44,7 @@ impl Default for GameManager {
3044 }
3145}
3246
47+
3348impl GameManager {
3449 /// Load a child game
3550 pub async fn launch_sub_game (
@@ -150,9 +165,10 @@ impl GameManager {
150165 }
151166 }
152167
153- pub async fn get_serving_addrs ( & self ) -> Vec < String > {
168+ pub async fn get_serving_games ( & self ) -> Vec < ServingGame > {
154169 let games = self . games . read ( ) . await ;
155- games. keys ( ) . cloned ( ) . collect ( )
170+
171+ games. iter ( ) . map ( |( addr, handle) | ServingGame :: new ( addr. to_owned ( ) , handle. bundle_addr ( ) ) ) . collect ( )
156172 }
157173
158174 pub async fn is_game_loaded ( & self , game_addr : & str ) -> bool {
0 commit comments