コード例 #1
0
        /// <summary>
        /// Prepares nodes info
        /// </summary>
        /// <param name="message"></param>
        /// <param name="sender"></param>
        private void PrepareNodeInfo(INyxMessage message, INyxNode sender)
        {
            NodeInfo nodeInfo;

            try
            {
                nodeInfo = NodeInfo.BuildInfo((INyxBorg)sender);
            }
            catch (Exception ex)
            {
                _logger.Error("Error building node info.", ex);
                return;
            }
            var plugs = _pluginManager.GetExtensions().Where(e => e.GetType().IsAssignableTo <IExtendNodeInfo>()).Cast <IExtendNodeInfo>();
            var sw    = Stopwatch.StartNew();
            Action <IExtendNodeInfo> act = p =>
            {
                sw.Restart();
                try
                {
                    p.AddExtraData(nodeInfo);
                }
                catch (Exception ex)
                {
                    _logger.Error($"Error adding extra info from type {p?.GetType().FullName}.", ex);
                }
                _logger.Trace("{0} took {1}ms to add node info.", p.GetType().FullName, sw.ElapsedMilliseconds);
            };

            sw.Stop();
            plugs.ForEach(act);
            message.Set(NodeManagerInfo, nodeInfo);
        }
コード例 #2
0
 /// <summary>
 ///     Allows all messages to pass, just add new info to them, or removes so they don't get into the borgs by mistake.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="sender"></param>
 /// <param name="error"></param>
 /// <returns></returns>
 public bool AllowMessage(INyxMessage message, INyxNode sender, out string error)
 {
     lock (FilterLock)
     {
         error = string.Empty;
         if (sender is INyxBorg)
         {
             if (message.Direction == MessageDirection.Out)
             {
                 PrepareNodeInfo(message, sender);
             }
             return(true);
         }
         var msg = message.AsReadOnly();
         // We use a queue
         _tasker.QueueTask(() =>
         {
             try
             {
                 RunNodeCollector(msg);
             }
             catch (Exception ex)
             {
                 _logger.Error("Error processing node info.", ex);
             }
         });
     }
     return(true);
 }
コード例 #3
0
ファイル: MessageStatus.cs プロジェクト: ycdivfx/nyx
 public MessageStatus(INyxNode sender, INyxMessage msg, MessageCondition condition, string description, bool hubReply)
 {
     Sender      = sender;
     Message     = msg;
     Status      = condition;
     IsHubReply  = hubReply;
     Description = description;
 }
コード例 #4
0
 public BasicHubAction(ILogger <BasicHubAction> logger, INyxNode hub)
 {
     _logger = logger;
     _hub    = hub as INyxHub;
     _name   = "basic";
     _supportedActions.AddRange(new[]
     {
         Register, Ping
     });
 }
コード例 #5
0
ファイル: MessageStatus.cs プロジェクト: ycdivfx/nyx
 public MessageStatus(INyxNode sender, INyxMessage msg, MessageCondition condition, bool hubReply) :
     this(sender, msg, condition, string.Empty, hubReply)
 {
 }
コード例 #6
0
ファイル: MessageStatus.cs プロジェクト: ycdivfx/nyx
 public MessageStatus(INyxNode sender, INyxMessage msg, MessageCondition condition, string description) :
     this(sender, msg, condition, description, false)
 {
 }
コード例 #7
0
ファイル: NyxNodeStatusMessage.cs プロジェクト: ycdivfx/nyx
 public NyxNodeStatusMessage(NyxNodeStatus status, INyxNode node)
 {
     NodeStatus = status;
     Node       = node;
 }
コード例 #8
0
ファイル: NyxMessageExtensions.cs プロジェクト: ycdivfx/nyx
 public static MessageStatus SuccessfullSent(this INyxMessage msg, INyxNode sender)
 {
     return(new MessageStatus(sender, msg.AsReadOnly(), MessageCondition.Sent));
 }
コード例 #9
0
ファイル: NyxMessageExtensions.cs プロジェクト: ycdivfx/nyx
 public static MessageStatus Filtered(this INyxMessage msg, INyxNode sender, string description)
 {
     return(new MessageStatus(sender, msg.AsReadOnly(), MessageCondition.Filtered, description));
 }
コード例 #10
0
 /// <summary>
 ///     Processes all messages, in all type of <see cref="INyxNode" />.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public bool CanFilter(INyxNode node, INyxMessage message = null)
 {
     return(true);
 }
コード例 #11
0
ファイル: ConnectionStatusInfo.cs プロジェクト: ycdivfx/nyx
 /// <summary>
 /// Connection status message construtor.
 /// </summary>
 /// <param name="node">Sender node</param>
 /// <param name="endpoint">Endpoint for the connection status.</param>
 /// <param name="status">Node connection status.</param>
 public ConnectionStatusInfo(ConnectionStatus status, string endpoint, INyxNode node)
 {
     Node     = node;
     Endpoint = endpoint;
     Status   = status;
 }