Exemplo n.º 1
0
        /// <summary>
        /// Gets the message to publish to emitter channel.
        /// </summary>
        /// <returns></returns>
        protected override void OnExecute()
        {
            // First, find all dead handles
            DebugHandle.Cleanup();

            try
            {
                // Send some objects
                var handles = new List <DebugHandle>();
                //foreach (var mesh in Service.Mesh.Members)
                //    handles.Add(DebugHandle.Inspect(mesh));
                handles.Add(
                    DebugHandle.Inspect(Service.Registry.Collection)
                    );

                /*foreach (var client in Service.Clients)
                 * {
                 *  if (client.Channel?.Binding is MeshBinding)
                 *      continue;
                 *  handles.Add(DebugHandle.Inspect(client));
                 * }*/

                if (handles.Count == 0)
                {
                    return;
                }

                // Return the serialized object
                var message = Encoding.UTF8
                              .GetBytes(JsonConvert.SerializeObject(handles))
                              .AsSegment();

                // Publish the message in the cluster, don't need to store it as it might slow everything down
                Dispatcher.Publish(SecurityLicense.Current.Contract, Info.Target, this.Channel + "root/", message, 60);
            }
            catch (Exception ex)
            {
                Service.Logger.Log(ex);
            }
        }