| Index: examples/echo/echo_server.cc
|
| diff --git a/examples/echo/echo_server.cc b/examples/echo/echo_server.cc
|
| index 6ff79a68826c38f04029bd8db85b2ddab5eb4a79..520f7b351eb668c45d6b0ea45901de085b27ce04 100644
|
| --- a/examples/echo/echo_server.cc
|
| +++ b/examples/echo/echo_server.cc
|
| @@ -7,9 +7,12 @@
|
| #include "mojo/public/c/system/main.h"
|
| #include "mojo/public/cpp/application/application_connection.h"
|
| #include "mojo/public/cpp/application/application_delegate.h"
|
| +#include "mojo/public/cpp/application/application_impl.h"
|
| #include "mojo/public/cpp/application/application_runner.h"
|
| #include "mojo/public/cpp/application/interface_factory.h"
|
| #include "mojo/public/cpp/bindings/strong_binding.h"
|
| +#include "mojo/public/cpp/utility/run_loop.h"
|
| +#include "mojo/services/vanadium/security/public/interfaces/principal.mojom.h"
|
|
|
| namespace mojo {
|
| namespace examples {
|
| @@ -48,15 +51,30 @@ class StrongBindingEchoImpl : public EchoImpl {
|
| mojo::StrongBinding<Echo> strong_binding_;
|
| };
|
|
|
| +class GetBlessingResponse {
|
| + public:
|
| + void Run(const BlessingPtr& b) const {
|
| + // EchoClient user identity is available as b.get()->chain
|
| + RunLoop::current()->Quit();
|
| + }
|
| +};
|
| +
|
| // MultiServer creates a new object to handle each message pipe.
|
| class MultiServer : public mojo::ApplicationDelegate,
|
| public mojo::InterfaceFactory<Echo> {
|
| public:
|
| MultiServer() {}
|
|
|
| + void Initialize(ApplicationImpl* app) override {
|
| + app->ConnectToService("mojo:go_principal_service", &login_service_);
|
| + }
|
| +
|
| // From ApplicationDelegate
|
| bool ConfigureIncomingConnection(
|
| mojo::ApplicationConnection* connection) override {
|
| + AppInstanceNamePtr app(AppInstanceName::New());
|
| + app->url = connection->GetRemoteApplicationURL();
|
| + login_service_->GetUserBlessing(app.Pass(), GetBlessingResponse());
|
| connection->AddService<Echo>(this);
|
| return true;
|
| }
|
| @@ -68,6 +86,9 @@ class MultiServer : public mojo::ApplicationDelegate,
|
| // StrongBinding<> for the declaration of |strong_binding_|.
|
| new StrongBindingEchoImpl(request.Pass());
|
| }
|
| +
|
| + private:
|
| + PrincipalServicePtr login_service_;
|
| };
|
|
|
| // SingletonServer uses the same object to handle all message pipes. Useful
|
|
|