Bloom.Api.CommandAvailabilityPublisher.CommandAvailabilityPublisher C# (CSharp) Method

CommandAvailabilityPublisher() public method

public CommandAvailabilityPublisher ( IEnumerable commands ) : System
commands IEnumerable
return System
        public CommandAvailabilityPublisher(IEnumerable<ICommand> commands )
        {
            foreach (var command in commands)
            {
                command.EnabledChanged += command_EnabledChanged;
            }

            FleckLog.Level = LogLevel.Warn;
            _allSockets = new List<IWebSocketConnection>();
            _server = new WebSocketServer("ws://127.0.0.1:8189");
            try
            {
                _server.Start(socket =>
                {
                    socket.OnOpen = () =>
                    {
                        Debug.WriteLine("Backend received an request to open a CommandAvailabilityPublisher socket");
                        _allSockets.Add(socket);
                    };
                    socket.OnClose = () =>
                    {
                        Debug.WriteLine("Backend received an request to close  CommandAvailabilityPublisher socket");
                        _allSockets.Remove(socket);
                    };
                });
            }
            catch (SocketException ex)
            {
                ErrorReport.NotifyUserOfProblem(ex, "Bloom cannot start properly (cannot set up some internal communications){0}{0}" +
                    "What caused this?{0}" +
                    "Possibly another version of Bloom is running, perhaps not very obviously.{0}{0}" +
                    "What can you do?{0}" +
                    "Click OK, then exit Bloom and restart your computer.{0}" +
                    "If the problem keeps happening, click 'Details' and report the problem to the developers.", Environment.NewLine);
            }
        }