internal SimpleLinkedList<Node> GetNodesForMessage(RelayMessage message) { SimpleLinkedList<Node> nodes = null; if (message == null || message.RelayTTL < 1 || NodeGroups == null) { return new SimpleLinkedList<Node>(); } const bool useLegacySerialization = true; //commands that, from out of system, route to all groups if (message.IsGroupBroadcastMessage) { message.PrepareMessageToBeSent(useLegacySerialization); if (MyNodeGroup == null)//out of system: all groups { nodes = new SimpleLinkedList<Node>(); for (int groupIndex = 0; groupIndex < this.NodeGroups.Count; groupIndex++) { nodes.Push(NodeGroups[groupIndex].GetNodesForMessage(message)); } } else//In system: my group { nodes = MyNodeGroup.MyCluster.GetNodesForMessage(message); } } else { //Commands that always route to a single group NodeGroup group = GetNodeGroup(message.TypeId); if (group != null) { message.PrepareMessageToBeSent(group.GroupDefinition.LegacySerialization); nodes = group.GetNodesForMessage(message); } else { message.PrepareMessageToBeSent(useLegacySerialization); if (_log.IsErrorEnabled) _log.ErrorFormat("No group found for {0}", message); nodes = new SimpleLinkedList<Node>(); } } if (nodes == null) { nodes = new SimpleLinkedList<Node>(); } // If no nodes are returned, we predict that the caller // will drop the message. Therefore we call the notification delegate. // This is admittedly a kludgy solution, but the only one // available without changing this method's signature. // A better solution should be adopted. [tchow 01/29/2008] if (nodes.Count == 0) { Forwarder.RaiseMessageDropped(message); } return nodes; }
internal SimpleLinkedList <Node> GetNodesForMessage(RelayMessage message) { SimpleLinkedList <Node> nodes = null; if (message == null || message.RelayTTL < 1 || NodeGroups == null) { return(new SimpleLinkedList <Node>()); } const bool useLegacySerialization = true; //commands that, from out of system, route to all groups if (message.IsGroupBroadcastMessage) { message.PrepareMessageToBeSent(useLegacySerialization); if (MyNodeGroup == null) //out of system: all groups { nodes = new SimpleLinkedList <Node>(); for (int groupIndex = 0; groupIndex < this.NodeGroups.Count; groupIndex++) { nodes.Push(NodeGroups[groupIndex].GetNodesForMessage(message)); } } else //In system: my group { nodes = MyNodeGroup.MyCluster.GetNodesForMessage(message); } } else { //Commands that always route to a single group NodeGroup group = GetNodeGroup(message.TypeId); if (group != null) { message.PrepareMessageToBeSent(group.GroupDefinition.LegacySerialization); nodes = group.GetNodesForMessage(message); } else { message.PrepareMessageToBeSent(useLegacySerialization); if (_log.IsErrorEnabled) { _log.ErrorFormat("No group found for {0}", message); } nodes = new SimpleLinkedList <Node>(); } } if (nodes == null) { nodes = new SimpleLinkedList <Node>(); } // If no nodes are returned, we predict that the caller // will drop the message. Therefore we call the notification delegate. // This is admittedly a kludgy solution, but the only one // available without changing this method's signature. // A better solution should be adopted. [tchow 01/29/2008] if (nodes.Count == 0) { Forwarder.RaiseMessageDropped(message); } return(nodes); }