Open henrywood opened 3 months ago
To be able to use RPC from your kphp scripts, you need to pass .tlo
scheme to compiler via -T path/to/scheme.tlo
. Otherwise, compiler can't generate serialization logic by according to TL scheme and hence you can't communicate via RPC. You can read about other compiler options in our documentation.
To compile .tl
scheme to .tlo
you need to provide at least one annotaion for each TL function. There's a special annotaion @kphp
for TL functions which will be served by kphp RPC server (exactly what you need). Check out examples here
https://github.com/VKCOM/kphp/blob/ee1122d36187f97018337792d037ccc48fb6051e/common/tl-files/common.tl#L117
So, you should do the following:
@kphp
annotation to your TL function.scheme.tlo
-T scheme.tlo
Also, I'd suggest to visit our chat in Telegram. There you probably get much faster answer
Could someone please provide an ultra-short example of how to respond to an UNTYPED RPC request ?
The documentation only appears to show how to do TYPED RPC ?
Let's say I have a service that takes in a string in 'fullname' member (of the associative array) and I want the service to respond with an int (the age), exactly how would the index.php look ?
This is my user.tl
This is my client.php
Compiling with:
Compiles OK.
server.php
Compiling with:
DOES NOT compile ?
The error is:
Line 18 is this line:
Compiling the user.tl file with
gives this error:
Running:
Running the client:
What am I doing wrong ???
Where exactly should the schema.tlo file be placed ? On the server and/or the client ? And how do I specify the path to it ???
Please help !