/// <inheritdoc/> public void RegisterNode(Node node, NodeLibrary dependency) { _loadedAssemblies.Add(node.GetType().Assembly); var fullName = node.GetType().FullName ?? string.Empty; if (_availableNodeViewModels.Contains(node)) { return; } if (_nodeNameToViewModelMap.ContainsKey(fullName)) { return; } if (_dependencyMap.ContainsKey(fullName)) { throw new InvalidOperationException($"Node registered twice with {GetType().AssemblyQualifiedName}"); } _nodeNameToViewModelMap.Add(fullName, node.GetType()); _availableNodeViewModels.Add(node); _dependencyMap.Add(fullName, dependency); NodeRegistered?.Invoke(node); }
public void Adds_node_to_store_on_NodeRegistered_message() { const ulong Id = 4; const string Type = "test"; var msg = new NodeRegistered(new RegisterMessage { Id = Id, Type = Type }, new IPEndPoint(IPAddress.Loopback, 123)); tracker.Handle(msg); A.CallTo(() => store.AddNode(Id, Type, A <IReadOnlyList <string> > .Ignored)) .MustHaveHappened(Repeated.Exactly.Once); }
public void ProcessMessage(MessageData message) { switch (message.Type) { case MessageType.Common: OnNormalMessage(); return; case MessageType.NodeSignal: OnNodeSignalMessage(); return; case MessageType.NodeInitialization: OnNewNode(); return; } void OnNewNode() { var nodeName = MessageCodec.DecodeNodeInitialization(message.Data); //var udpSigWorker = new NodeSignalsWorker(message.Identity, m_signalsProcessor.SendSignalBuffer); var tcpSigWorker = new NodeMainTCPSignalWorker(message.Identity, m_signalsProcessor.SendSignalBuffer); var cmdSigWorker = new NodeCommandSignalWorker(message.Identity, m_signalsProcessor.SendSignalBuffer); var node = new Node(message.Identity, nodeName, //udpSigWorker, tcpSigWorker, cmdSigWorker); m_nodes.Add(message.Identity, node); node.OutMessageBuffer.LinkTo(SendMessageBuffer); node.CommandOutMessageBuffer.LinkTo(SendCommandBuffer); NodeRegistered?.Invoke(this, new NodeRegisteredEventArgs(node)); node.TCPSocketSignalsWorker.SendNullSignal(); } void OnNodeSignalMessage() { if (m_nodes.TryGetValue(message.Identity, out var node)) { m_signalsProcessor.RecvSignalBuffer.Post(( //(message.Protocol == TransportProtocol.TCP) ? node.TCPSocketSignalsWorker, //: //node.UDPSocketSignalsWorker, message.Data)); } else { OnUninitializedMessage(); } } void OnNormalMessage() { if (m_nodes.TryGetValue(message.Identity, out var node)) { node.InMessageBuffer.Post(message.Data); } else { OnUninitializedMessage(); } } }
public void Handle(NodeRegistered notification) { logger.Debug($"Registering new node {notification.Message.Id}."); csDataStore.AddNode(notification.Message.Id, notification.Message.Type, notification.Message.SolvableProblems); }