// Launch a proxy thread that transform DursMsgContent() to GvaMsg::DursMsgContent(DursMsgContent())
letrouter_sender_clone=router_sender.clone();
letgva_sender_clone=gva_sender.clone();
thread::spawn(move||{
// Send gva module registration to router thread
// Send gva module registration to router thread
router_sender_clone
router_sender
.send(RouterThreadMessage::ModuleRegistration{
.send(RouterThreadMessage::ModuleRegistration{
static_name:ModuleStaticName(MODULE_NAME),
static_name:ModuleStaticName(MODULE_NAME),
sender:proxy_sender,// Messages sent by the router will be received by your proxy thread
sender:gva_sender,// Messages sent by the router will be received by your proxy thread
roles:vec![ModuleRole::UserInterface],// Roles assigned to your module
roles:vec![ModuleRole::UserInterface],// Roles assigned to your module
events_subscription:vec![ModuleEvent::NewValidBlock],// Events to which your module subscribes
events_subscription:vec![ModuleEvent::NewValidBlock],// Events to which your module subscribes
reserved_apis_parts:vec![],
reserved_apis_parts:vec![],
endpoints:vec![],
endpoints:vec![],
})
})
.expect("Fatal error : gva module fail to register to router !");// The registration of your module must be successful, in case of failure the program must be interrupted.
.expect("Fatal error : gva module fail to register to router !");// The registration of this module must be successful, in case of failure the program must be interrupted.
// If we are here it means that your module has successfully registered, we indicate it in the debug level log, it can be helpful.
// If we are here it means that this module has successfully registered,
// we indicate it in the debug level log, it can be helpful.
debug!("Send gva module registration to router thread.");
debug!("Send gva module registration to router thread.");
/*
* Main loop of your proxy thread
*/
loop{
matchproxy_receiver.recv(){
Ok(message)=>{
letstop=ifletDursMsg::Stop=message{
true
}else{
false
};
ifgva_sender_clone
.send(GvaMsg::DursMsg(Box::new(message)))
.is_err()
{
// Log error
warn!("Gva proxy : fail to relay DursMsg to gva main thread !")