Skip to content

Commit d622ed9

Browse files
authored
[GenShowcase] Update event index syntax (#937)
1 parent 391f03b commit d622ed9

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

examples/GeneratorShowcase/GeneratorShowcase.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,26 +1858,23 @@ namespace Plugin {
18581858
Example::JSimpleInstanceObjects::Event::StateChanged(*this, object, device->State(), client);
18591859
}
18601860
}
1861-
void OnPinChangedEventRegistration(Example::ISimpleInstanceObjects::IDevice* object, const string& client, const PluginHost::JSONRPCSupportsEventStatus::Status status) override
1861+
void OnPinChangedEventRegistration(Example::ISimpleInstanceObjects::IDevice* object, const string& client, const string& index, const PluginHost::JSONRPCSupportsEventStatus::Status status) override
18621862
{
18631863
string name;
18641864
static_cast<const Example::ISimpleInstanceObjects::IDevice*>(object)->Name(name);
18651865

1866-
TRACE(Trace::Information, (_T("Client '%s' %s for device '%s' pin state change notifications"), client.c_str(),
1867-
status == PluginHost::JSONRPCSupportsEventStatus::Status::registered? "registered" : "unregistered", name.c_str()));
1866+
TRACE(Trace::Information, (_T("Client '%s' %s for device '%s' pin %s state change notifications"), client.c_str(),
1867+
status == PluginHost::JSONRPCSupportsEventStatus::Status::registered? "registered" : "unregistered", name.c_str(), index.c_str()));
18681868

18691869
// A JSON-RPC client registered for "pinchanged" notifications, let them know the state if the pin is lit already.
18701870
// Only the registering client will recieve this extra notification, via the default sendif method generated.
1871-
// The client designator also carries index of the pin.
18721871
if (status == PluginHost::JSONRPCSupportsEventStatus::Status::registered) {
18731872
ImaginaryHost::DeviceImpl* device = static_cast<ImaginaryHost::DeviceImpl*>(object);
18741873

1875-
device->IteratePins([this, object, client](const uint8_t index, const bool high) {
1876-
1877-
if (high == true) {
1878-
Example::JSimpleInstanceObjects::Event::PinChanged(*this, object, index, true, client);
1879-
}
1880-
});
1874+
const uint8_t pin = ::atoi(index.c_str());
1875+
if (device->PinStatus(pin) == true) {
1876+
Example::JSimpleInstanceObjects::Event::PinChanged(*this, object, pin, true, client);
1877+
}
18811878
}
18821879
}
18831880

examples/GeneratorShowcase/doc/GeneratorShowcasePlugin.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ Signals completion of the Connect method.
20262026

20272027
### Parameters
20282028

2029-
> The *address* parameter shall be passed within the *id* parameter to the ``register`` call, i.e. ``<address>.<client-id>``.
2029+
> The *address* parameter shall be passed as index to the ``register`` call, i.e. ``register@<address>``.
20302030
20312031
### Notification Parameters
20322032

@@ -2043,10 +2043,10 @@ Signals completion of the Connect method.
20432043
{
20442044
"jsonrpc": "2.0",
20452045
"id": 42,
2046-
"method": "GeneratorShowcase.1.register",
2046+
"method": "GeneratorShowcase.1.register@[11,22]",
20472047
"params": {
20482048
"event": "bindingChanged",
2049-
"id": "[11,22].myid"
2049+
"id": "myid"
20502050
}
20512051
}
20522052
```
@@ -2056,16 +2056,14 @@ Signals completion of the Connect method.
20562056
```json
20572057
{
20582058
"jsonrpc": "2.0",
2059-
"method": "[11,22].myid.bindingChanged",
2059+
"method": "myid.bindingChanged@[11,22]",
20602060
"params": {
20612061
"bound": false
20622062
}
20632063
}
20642064
```
20652065

2066-
> The *client ID* parameter is passed within the notification designator, i.e. ``<address>.<client-id>.bindingChanged``.
2067-
2068-
> The *address* parameter is passed within the notification designator, i.e. ``<address>.<client-id>.bindingChanged``.
2066+
> The *client ID* parameter is passed within the notification designator, i.e. ``<client-id>.bindingChanged@<address>``.
20692067
20702068
<a id="notification_statusChanged"></a>
20712069
## *statusChanged [<sup>notification</sup>](#head_Notifications)*
@@ -2214,7 +2212,7 @@ Signals pin state changes.
22142212
22152213
### Parameters
22162214

2217-
> The *pin* parameter shall be passed within the *id* parameter to the ``register`` call, i.e. ``<pin>.<client-id>``.
2215+
> The *pin* parameter shall be passed as index to the ``register`` call, i.e. ``register@<pin>``.
22182216
22192217
### Notification Parameters
22202218

@@ -2231,10 +2229,10 @@ Signals pin state changes.
22312229
{
22322230
"jsonrpc": "2.0",
22332231
"id": 42,
2234-
"method": "GeneratorShowcase.1.device#id1::register",
2232+
"method": "GeneratorShowcase.1.device#id1::register@0",
22352233
"params": {
22362234
"event": "pinChanged",
2237-
"id": "0.myid"
2235+
"id": "myid"
22382236
}
22392237
}
22402238
```
@@ -2244,18 +2242,16 @@ Signals pin state changes.
22442242
```json
22452243
{
22462244
"jsonrpc": "2.0",
2247-
"method": "0.myid.device#id1::pinChanged",
2245+
"method": "myid.device#id1::pinChanged@0",
22482246
"params": {
22492247
"high": false
22502248
}
22512249
}
22522250
```
22532251

2254-
> The *client ID* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.
2255-
2256-
> The *pin* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.
2252+
> The *client ID* parameter is passed within the notification designator, i.e. ``<client-id>.device#<device-id>::pinChanged@<pin>``.
22572253
2258-
> The *device instance id* parameter is passed within the notification designator, i.e. ``<pin>.<client-id>.device#<device-id>::pinChanged``.
2254+
> The *device instance id* parameter is passed within the notification designator, i.e. ``<client-id>.device#<device-id>::pinChanged@<pin>``.
22592255
22602256
<a id="notification_added"></a>
22612257
## *added [<sup>notification</sup>](#head_Notifications)*

0 commit comments

Comments
 (0)