-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathclient_demo_2.py
More file actions
37 lines (33 loc) · 966 Bytes
/
client_demo_2.py
File metadata and controls
37 lines (33 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
#!
# client_demo_2.py
# Client performs method call and receives time stamp from the server.
#
# Ian Stewart
# 2019-11-22
#
# Importing.
from pydbus import SessionBus # from pydbus import SystemBus
from gi.repository import GLib
# Instantiation, Constants, Variables...
bus = SessionBus()
BUS = "org.example.demo.test"
server_object = bus.get(BUS)
loop = GLib.MainLoop()
INTERVAL = 2
def make_method_call_client_2():
"Server returns a time stamp."
reply = server_object.get_time_stamp()
print("Returned data is of type: {}".format(type(reply)))
print("Time stamp received from server: {}".format(reply))
return True
if __name__=="__main__":
print("Starting Client Demo 2...")
GLib.timeout_add_seconds(interval=INTERVAL,
function=make_method_call_client_2)
loop.run()
"""
Notes:
1. Launch server_demo_2.py in one console
2. Then launch client_demo_2.py in another console.
"""