diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index 5ebed44e..2785a037 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -1034,15 +1034,18 @@ class CoreGrpcClient: response = self.stub.GetNodeConfigService(request) return dict(response.config) - def get_emane_event_channel(self, session_id: int) -> wrappers.EmaneEventChannel: + def get_emane_event_channel( + self, session_id: int, nem_id: int + ) -> wrappers.EmaneEventChannel: """ Retrieves the current emane event channel being used for a session. :param session_id: session to get emane event channel for + :param nem_id: nem id for the desired event channel :return: emane event channel :raises grpc.RpcError: when session doesn't exist """ - request = GetEmaneEventChannelRequest(session_id=session_id) + request = GetEmaneEventChannelRequest(session_id=session_id, nem_id=nem_id) response = self.stub.GetEmaneEventChannel(request) return wrappers.EmaneEventChannel.from_proto(response) diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index e2851964..8b0b903a 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -1241,12 +1241,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): self, request: GetEmaneEventChannelRequest, context: ServicerContext ) -> GetEmaneEventChannelResponse: session = self.get_session(request.session_id, context) - group = None - port = None - device = None - if session.emane.eventchannel: - group, port, device = session.emane.eventchannel - return GetEmaneEventChannelResponse(group=group, port=port, device=device) + service = session.emane.nem_service.get(request.nem_id) + if not service: + context.abort(grpc.StatusCode.NOT_FOUND, f"unknown nem id {request.nem_id}") + return GetEmaneEventChannelResponse( + group=service.group, port=service.port, device=service.device + ) def ExecuteScript(self, request, context): existing_sessions = set(self.coreemu.sessions.keys()) diff --git a/daemon/core/emane/emanemanager.py b/daemon/core/emane/emanemanager.py index 47279592..5a403c20 100644 --- a/daemon/core/emane/emanemanager.py +++ b/daemon/core/emane/emanemanager.py @@ -7,7 +7,7 @@ import os import threading from dataclasses import dataclass, field from enum import Enum -from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Type, Union +from typing import TYPE_CHECKING, Dict, List, Optional, Set, Type, Union from core import utils from core.emane.emanemodel import EmaneModel @@ -158,7 +158,6 @@ class EmaneManager: # emane event monitoring self.services: Dict[str, EmaneEventService] = {} self.nem_service: Dict[int, EmaneEventService] = {} - self.eventchannel: Optional[Tuple[str, int, str]] = None def next_nem_id(self, iface: CoreInterface) -> int: nem_id = self.session.options.get_config_int("nem_id_start") diff --git a/daemon/proto/core/api/grpc/emane.proto b/daemon/proto/core/api/grpc/emane.proto index 1e56a0aa..5aa0c952 100644 --- a/daemon/proto/core/api/grpc/emane.proto +++ b/daemon/proto/core/api/grpc/emane.proto @@ -33,6 +33,7 @@ message GetEmaneModelConfig { message GetEmaneEventChannelRequest { int32 session_id = 1; + int32 nem_id = 2; } message GetEmaneEventChannelResponse {