/// <summary>
        /// Builds the plugin
        /// </summary>
        /// <param name="ctx">HostPluginBuildContext instance used to build the plugin.</param>
        public void Build(HostPluginBuildContext ctx)
        {
            var service = new ClientLogsService();

            ctx.SceneCreating += scene =>
            {
                scene.Metadata.Add(ClientLogsPluginConstants.PluginName, ClientLogsPluginConstants.Version);

                scene.RegisterComponent(() => service);

                scene.AddRoute(ClientLogsPluginConstants.ClientLogsRoute, p =>
                {
                    string shouldLogClient;
                    if (p.Connection.Metadata.TryGetValue(ClientLogsPluginConstants.isLoggingMetadataKey, out shouldLogClient) && shouldLogClient == "True")
                    {
                        var logger = scene.GetComponent <ILogger>();
                        var log    = p.ReadObject <LogMsg>();
                        logger.Log(log.Level, "client." + log.Category, log.Message, log.Data);
                    }
                });
            };
        }
        /// <summary>
        /// Registers the plugin
        /// </summary>
        /// <param name="ctx">A plugin registration context</param>
        public void Build(HostPluginBuildContext ctx)
        {
            ctx.SceneDependenciesRegistration += (IDependencyBuilder db, ISceneHost scene) =>
            {
                db.Register <RpcService>().InstancePerScene();
            };

            ctx.SceneCreated += (ISceneHost scene) =>
            {
                scene.Metadata.Add(PluginName, Version);

                var processor = scene.DependencyResolver.Resolve <RpcService>();

                // Register(processor);
                scene.AddRoute(NextRouteName, p =>
                {
                    processor.Next(p);
                    return(Task.FromResult(true));
                }, o => o.AutoDisposePacketStream(false));
                scene.AddRoute(CancellationRouteName, p =>
                {
                    processor.Cancel(p);
                    return(Task.FromResult(true));
                }, o => o);
                scene.AddRoute(ErrorRouteName, p =>
                {
                    processor.Error(p);
                    return(Task.FromResult(true));
                }, o => o);
                scene.AddRoute(CompletedRouteName, p =>
                {
                    processor.Complete(p);
                    return(Task.FromResult(true));
                }, o => o);


                scene.AddInternalRoute(NextRouteName, async p =>
                {
                    processor.Next(p);
                    await Task.FromResult(true);
                }, o => o.AutoDisposePacketStream(false));
                scene.AddInternalRoute(CancellationRouteName, p =>
                {
                    processor.Cancel(p);
                    return(Task.FromResult(true));
                }, o => o);
                scene.AddInternalRoute(ErrorRouteName, p =>
                {
                    processor.Error(p);
                    return(Task.FromResult(true));
                }, o => o);
                scene.AddInternalRoute(CompletedRouteName, p =>
                {
                    processor.Complete(p);
                    return(Task.FromResult(true));
                }, o => o);

                scene.Disconnected.Add(processor.PeerDisconnected);
                scene.Shuttingdown.Add(processor.SceneShuttingDown);
            };
        }