docs: added examples for listening to events in grpc/python

This commit is contained in:
Blake Harnden 2020-09-13 09:26:48 -07:00
parent 4bdc454970
commit 4538675c90
2 changed files with 45 additions and 2 deletions

View file

@ -87,7 +87,28 @@ iface_data = iface_helper.create_iface(
### Listening to Events
TBD
Various events that can occur within a session can be listened to.
Event types:
* session - events for changes in session state and mobility start/stop/pause
* node - events for node movements and icon changes
* link - events for link configuration changes and wireless link add/delete
* config - configuration events when legacy gui joins a session
* exception - alert/error events
* file - file events when the legacy gui joins a session
```python
from core.api.grpc import core_pb2
def event_listener(event):
print(event)
# provide no events to listen to all events
core.events(session_id, event_listener)
# provide events to listen to specific events
core.events(session_id, event_listener, [core_pb2.EventType.NODE])
```
### Configuring Links

View file

@ -66,7 +66,29 @@ iface_data = ip_prefixes.create_iface(
### Listening to Events
TBD
Various events that can occur within a session can be listened to.
Event types:
* session - events for changes in session state and mobility start/stop/pause
* node - events for node movements and icon changes
* link - events for link configuration changes and wireless link add/delete
* config - configuration events when legacy gui joins a session
* exception - alert/error events
* file - file events when the legacy gui joins a session
```python
def event_listener(event):
print(event)
# add an event listener to event type you want to listen to
# each handler will receive an object unique to that type
session.event_handlers.append(event_listener)
session.exception_handlers.append(event_listener)
session.node_handlers.append(event_listener)
session.link_handlers.append(event_listener)
session.file_handlers.append(event_listener)
session.config_handlers.append(event_listener)
```
### Configuring Links