public AssignRoleToNodeCommandHandlerTests()
        {
            IBoutRunnerService boutRunnerService = new BoutRunnerService();

            _nodeService = new NodeService(boutRunnerService);
            _nodeService.ConnectNode("nodeId", "connectionId");
        }
        public RemoveRoleFromNodeCommandHandlerTests()
        {
            IBoutRunnerService boutRunnerService = new BoutRunnerService();

            _nodeService = new NodeService(boutRunnerService);
            _nodeService.ConnectNode("nodeId", "connectionId");
            _nodeService.AddRole("nodeId", "role");
        }
        public AddNodeToBoutCommandHandlerTests()
        {
            _nodeService = new NodeService(_boutRunnerService);
            _handler     = new AddNodeToBoutCommandHandler(_boutRunnerService, _nodeService, _boutDataService);
            _nodeService.ConnectNode("nodeId", "connectionId");
            var bout = _boutDataService.Load(Guid.Empty);

            _boutRunnerService.StartBout(bout);
        }
        public override ICommandResponse Handle(ConnectNodeCommand command)
        {
            var response   = new CommandResponse();
            var connection = _nodeService.ConnectNode(command.Originator, command.ConnectionId);

            response.AddEvent(new NodeConnectedEvent(connection), Audiences.All);
            if (connection.BoutId != Guid.Empty)
            {
                var bout      = _boutData.Load(connection.BoutId);
                var boutState = _boutRunnerService.GetBoutState(connection.BoutId);
                response.AddEvent(new InitializeBoutEvent(bout, boutState), command.ConnectionId);
            }
            return(response);
        }
Beispiel #5
0
 public ActionResult Connect(int?nid)
 {
     using (var db = new CoinpanicContext())
     {
         var sn = db.SeedNodes.AsNoTracking().FirstOrDefault(n => n.SeedNodeId == nid);
         nodeService.ConnectNode(
             new NodeDetails()
         {
             coin = nodeService.Coin,
             ip   = sn.IP,
             port = sn.Port,
             use  = sn.Enabled,
         }, force: true);
     }
     return(RedirectToAction("Index"));
 }