Closed sigiesec closed 6 years ago
An example for the following event in Idl:
event DataModelChanged [guid = 9BFE9AB7-3AA6-441F-82D7-D1A27F6321CE] (DataModelEventArgs);
the actuel added code in Dispatcher:
Member attribute:
Commons::Core::UniquePtr<Commons::CoreExtras::IObserver<ServiceAPI::DataModelEventArgs>> remoteDataModelEventPublisher;
in AttachEndpoint:
void CFieldDataDispatcher::AttachEndpoint(BTC::ServiceComm::API::IServerEndpoint &endpoint) { ... this->remoteDataModelEventPublisher = CreateRemoteEventPublisher<ServiceAPI::DataModelEventArgs, Protobuf::DataModelEventArgs>(endpoint); }
template<typename ServiceEventT, typename ProtoEventT>
BTC::Commons::Core::UniquePtr<Commons::CoreExtras::IObserver<ServiceEventT>> CFieldDataDispatcher::CreateRemoteEventPublisher(
ServiceComm::API::IServerEndpoint& endpoint) {
return ServiceComm::Util::CreateRemoteEventPublisher<ServiceEventT>(
GetDispatchee(),
endpoint.GetEventRegistry(),
[this](ServiceEventT const& event) -> ServiceComm::Commons::MessagePtr {
return MarshalEvent<ServiceEventT, ProtoEventT>(event);
},
ServiceEventT::EVENT_TYPE_GUID());
}
template<typename ServiceEventT, typename ProtoEventT>
ServiceComm::Commons::MessagePtr CFieldDataDispatcher::MarshalEvent(const ServiceEventT& serviceEvent) {
ServiceComm::Commons::MessagePtr message(GetMessagePool().Borrow());
ProtoEventT eventProtobuf;
FieldLink::Protobuf::FieldDataCodec::Encode(serviceEvent, &eventProtobuf);
message->PushBack(ServiceComm::ProtobufUtil::ProtobufSupport::ProtobufToMessagePart(GetMessagePartPool(), eventProtobuf));
return Move(message);
}
in DeleteEndpoint:
void CFieldDataDispatcher::DetachEndpoint(BTC::ServiceComm::API::IServerEndpoint &endpoint) { this->remoteDataPointValueDoubleEventPublisher.Clear(); ... }
And for the Interface:
class IFieldData : public virtual Commons::CoreExtras::IObservableRegistration<DataModelEventArgs>, ... { ... }
@isabusar Thanks for providing this information!
In Dispatcher (The class C***Dispatcher):
The API