29 #include "../../MetaData.h"
30 #include "../../EventId.h"
31 #include "../../Scope.h"
40 bool exposeWireSchema) {
45 MetaData& metaData =
event->mutableMetaData();
46 metaData.
setCreateTime((boost::uint64_t) notification.meta_data().create_time());
47 metaData.
setSendTime((boost::uint64_t) notification.meta_data().send_time());
52 (boost::uint8_t*) notification.event_id().sender_id().c_str()),
53 notification.event_id().sequence_number());
54 event->setScopePtr(
ScopePtr(
new Scope(notification.scope())));
55 if (notification.has_method()) {
56 event->setMethod(notification.method());
59 for (
int i = 0; i < notification.meta_data().user_infos_size(); ++i) {
60 metaData.
setUserInfo(notification.meta_data().user_infos(i).key(),
61 notification.meta_data().user_infos(i).value());
63 for (
int i = 0; i < notification.meta_data().user_times_size(); ++i) {
64 metaData.
setUserTime(notification.meta_data().user_times(i).key(),
65 notification.meta_data().user_times(i).timestamp());
67 for (
int i = 0; i < notification.causes_size(); ++i) {
68 event->addCause(
EventId(rsc::misc::UUID((boost::uint8_t*) notification.causes(i).sender_id().c_str()),
69 notification.causes(i).sequence_number()));
72 event->setData(boost::shared_ptr<string>(
new string(notification.data())));
74 if (exposeWireSchema) {
75 metaData.
setUserInfo(
"rsb.wire-schema", notification.wire_schema());
83 const string& wireSchema,
85 notification.mutable_event_id()->set_sender_id(
86 event->getMetaData().getSenderId().getId().data,
87 event->getMetaData().getSenderId().getId().size());
88 notification.mutable_event_id()->set_sequence_number(
89 event->getEventId().getSequenceNumber());
90 notification.set_scope(event->getScopePtr()->toString());
91 if (!event->getMethod().empty()) {
92 notification.set_method(event->getMethod());
94 notification.set_wire_schema(wireSchema);
95 notification.mutable_meta_data()->set_create_time(
96 event->getMetaData().getCreateTime());
97 notification.mutable_meta_data()->set_send_time(
98 event->getMetaData().getSendTime());
99 for (map<string, string>::const_iterator it =
100 event->mutableMetaData().userInfosBegin(); it
101 !=
event->mutableMetaData().userInfosEnd(); ++it) {
102 protocol::UserInfo* info =
103 notification.mutable_meta_data()->mutable_user_infos()->Add();
104 info->set_key(it->first);
105 info->set_value(it->second);
107 for (map<string, boost::uint64_t>::const_iterator it =
108 event->mutableMetaData().userTimesBegin(); it
109 !=
event->mutableMetaData().userTimesEnd(); ++it) {
110 protocol::UserTime* info =
111 notification.mutable_meta_data()->mutable_user_times()->Add();
112 info->set_key(it->first);
113 info->set_timestamp(it->second);
116 set<EventId> causes =
event->getCauses();
117 for (set<EventId>::const_iterator it = causes.begin();
118 it != causes.end(); ++it) {
119 protocol::EventId* cause = notification.mutable_causes()->Add();
120 cause->set_sender_id(it->getParticipantId().getId().data,
121 it->getParticipantId().getId().size());
122 cause->set_sequence_number(it->getSequenceNumber());
125 notification.set_data(data);