grpc: fix node events to include the config services on a node, allows dynamically added nodes to show their services within the gui

This commit is contained in:
Blake Harnden 2022-12-09 09:32:49 -08:00
parent a84e689478
commit 88a52f6cd2

View file

@ -13,6 +13,7 @@ from core.emulator.data import (
NodeData, NodeData,
) )
from core.emulator.session import Session from core.emulator.session import Session
from core.nodes.base import CoreNodeBase
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -30,6 +31,9 @@ def handle_node_event(node_data: NodeData) -> core_pb2.Event:
lon, lat, alt = node.position.get_geo() lon, lat, alt = node.position.get_geo()
geo = core_pb2.Geo(lon=lon, lat=lat, alt=alt) geo = core_pb2.Geo(lon=lon, lat=lat, alt=alt)
services = [x.name for x in node.services] services = [x.name for x in node.services]
config_services = []
if isinstance(node, CoreNodeBase):
config_services = [x for x in node.config_services]
node_proto = core_pb2.Node( node_proto = core_pb2.Node(
id=node.id, id=node.id,
name=node.name, name=node.name,
@ -38,6 +42,7 @@ def handle_node_event(node_data: NodeData) -> core_pb2.Event:
position=position, position=position,
geo=geo, geo=geo,
services=services, services=services,
config_services=config_services,
) )
message_type = node_data.message_type.value message_type = node_data.message_type.value
node_event = core_pb2.NodeEvent(message_type=message_type, node=node_proto) node_event = core_pb2.NodeEvent(message_type=message_type, node=node_proto)