First working version of capability interfaces
This commit is contained in:
25
examples/example_capability.py
Normal file
25
examples/example_capability.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import capnp
|
||||
import example_capability_capnp
|
||||
|
||||
class Server:
|
||||
def foo(self, context):
|
||||
context.results.x = str(context.params.i * 5 + 1)
|
||||
|
||||
def example_client():
|
||||
loop = capnp.EventLoop()
|
||||
|
||||
client = example_capability_capnp.TestInterface.new_client(Server(), loop)
|
||||
|
||||
req = client.request('foo')
|
||||
req = client.request('foo2')
|
||||
req.i = 5
|
||||
|
||||
remote = req.send()
|
||||
response = loop.wait_remote(remote)
|
||||
|
||||
print(response.x)
|
||||
|
||||
if __name__ == '__main__':
|
||||
example_client()
|
||||
Reference in New Issue
Block a user