@@ -28,6 +28,7 @@ async fn main() {
28
28
29
29
// create configured components
30
30
let mut config = config:: load_config ( config_file) . expect ( "failed to load configuration" ) ;
31
+ let _guard = config. tracing . setup_tracing_subscriber ( ) ;
31
32
32
33
info ! ( %config_file, %local_agent, %remote_agent, "starting client" ) ;
33
34
@@ -36,11 +37,18 @@ async fn main() {
36
37
let svc = config. services . get_mut ( & id) . unwrap ( ) ;
37
38
38
39
// create local agent
39
- let agent_name = encode_agent_from_string ( "cisco" , "default" , local_agent, 0 ) ;
40
+ let agent_id = 0 ;
41
+ let agent_name = encode_agent_from_string ( "cisco" , "default" , local_agent, agent_id) ;
40
42
let mut rx = svc. create_agent ( agent_name. clone ( ) ) ;
41
43
42
44
// connect to the remote gateway
43
45
let conn_id = svc. connect ( None ) . await . unwrap ( ) ;
46
+ info ! ( "remote connection id = {}" , conn_id) ;
47
+
48
+ let local_agent_class = encode_agent_class ( "cisco" , "default" , local_agent) ;
49
+ svc. subscribe ( & local_agent_class, Some ( agent_id) , conn_id)
50
+ . await
51
+ . unwrap ( ) ;
44
52
45
53
// Set a route for the remote agent
46
54
let route = encode_agent_class ( "cisco" , "default" , remote_agent) ;
@@ -74,10 +82,10 @@ async fn main() {
74
82
}
75
83
76
84
// send a message back
77
- let msg = "hello from the other side" ;
85
+ let msg = format ! ( "hello from the {}" , local_agent ) ;
78
86
svc. publish ( & route, None , 1 , msg. into ( ) ) . await . unwrap ( ) ;
79
87
80
88
// sleep
81
- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 10 ) ) . await ;
89
+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 1 ) ) . await ;
82
90
}
83
91
}
0 commit comments