Hello everyone,
I am user germandiagogomez from Github. I opened before a couple of isues, so that you can identify who I am :)
It is my first post in the mailing lists. After some research, I could not find definitive answers to my questios anywhere.
Some context
I
am using capnproto for a service where people connect and create rooms
and join them to play matches in a small game. So far so good :) Now, I
am in the need to implement a command that logs outs all users
from the admin interface for the server.
My implementation is something like this (simplified). I have:
a. game cilent
b. an admin commands console to talk to the server for admin purposes, independent of the game client
These are the capnproto interfaces I have implemented in C++ code:
1.
class OnlineRoomsAccess with a method authenticate and another method
authenticateAsAdmin that are used to log in into the server
to interact with it. These 2 calls will return another object of their respective type to use some capabilities.
2.
class OnlineRoomsService that is returned after calling
onlineRoomsAccessObj.authenticate(params) in my game client. It can be
used to create/join rooms, etc.
3. class
OnlineRoomsAdmin that is returned after calling
onlineRoomsAccessObj.authenticateAsAdmin(params). I can issue a call to
logoutAllUsers
with this interface. I created a cli to send this command.
My game client C++ code, looks like this at some point, when I issue an authenticate request:
// Authenticate + use flow
auto authRequest = accessObj.authenticateRequest();
authRequest.setUserName("myUser");
...
auto authResponse = authRequest.send().wait(...);
OnlineRoomsService::Client onlineRoomsService = authResponse.getService();
//Now create/join rooms, etc.
onlineRoomsService.createRoom(....);
My
server has something like this in OnlineRoomsAccesss::authenticate to
give the object capability to the user that requested it:
kj::Promise<void> authenticate(AuthenticateContext context) override {
...
context.getResults().setService(kj::heap<OnlineRoomsService>());
...
}
As
you can see, I use setService in the implementation of
OnlineRoomsAccess::authenticate and I do not hold myself a reference to
OnlineRoomsService object myself anymore after
creating it via
kj::heap. I just send it through the response to the request. As far as
I understand, kj::heap<T> is the equivalent of
std::unique_ptr<T>, correct me if I am wrong.
Question
1.
when my admin tool issues a logoutAllUsers() after I authenticate as
admin, and a client is connected, how can I revoke the capability to its
user?
Because I do not see an obvious way to do it on the
server side. I do not have an object or anything to destroy/dispose
after
context.getResults().setService(kj::heap<OnlineRoomsService>())
has been called... and I do not want to stop the server either.
I saw the proxy trick (which I did not understand fully yet) with
dispatchCall in the server for 0.5. Is this still the better way to
achieve this functionality?
Thanks for your time