Exemplo n.º 1
0
        public ConnService(HubConnection connection)
        {
            this._connection = connection;

            /* All signalR responses are received here and respective action invoke*/

            _connection.On <StatusModel>("ReceiveStatus", (status) => StatusReceived?.Invoke(status));
            _connection.On <Sender>("UpdateAlerts", (sender) => HandleEventReceived?.Invoke(sender));
            _connection.On <CasesModel>("AlertBroadcast", (sender) => AlertReceived?.Invoke(sender));
            _connection.On <string, string, string>("SMSSendingSuccess", (Sid, view, agent) => SendingSuccess?.Invoke(Sid, view, agent));
            _connection.On <string, string>("SMSResponseSuccess", (Sid, response) => ResponseSuccess?.Invoke(Sid, response));
            _connection.On <string>("NewUserConnected", (id) => NewUserSync?.Invoke(id));
            _connection.On <List <UsersRank> >("UsersRank", (rank) => Ranking?.Invoke(rank));
            _connection.On <string>("DisconnectUser", (connId) => DisconnectUser?.Invoke(connId));
            _connection.On <ResponseViewModel, string>("ProgressReportA", (obj, id) => ProgressReportA?.Invoke(obj, id));
            _connection.On <EMTInfo, string>("ProgressReportB", (obj, id) => ProgressReportB?.Invoke(obj, id));
            _connection.On <MedicalInfo, string>("ProgressReportC", (obj, id) => ProgressReportC?.Invoke(obj, id));
            _connection.On <string>("Test", (obj) => Test?.Invoke(obj));
            _connection.On <string>("RestartedResponse", (obj) => Restarted?.Invoke(obj));
            _connection.On <string, string, string>("CallSuccess", (sid, sender, agent) => CallSuccess?.Invoke(sid, sender, agent));
        }
Exemplo n.º 2
0
 public virtual void OnRestart(Action baseOnRestart)
 {
     baseOnRestart();
     Restarted?.Invoke(Target, EventArgs.Empty);
 }
Exemplo n.º 3
0
 private void OnEndGamePanelRestartButtonClicked()
 {
     Restarted?.Invoke();
 }
Exemplo n.º 4
0
 public void OnRestart(string msg)
 {
     Restarted?.Invoke(msg);
 }
Exemplo n.º 5
0
        private void OnProcessExited(object sender, EventArgs e)
        {
            OutputDataReceived?.Invoke(this, new OutputDataReceivedEventArgs("IBGateway process exited"));

            if (_isRestartInProgress)
            {
                _ibAutomaterInitializeEvent.Reset();

                OutputDataReceived?.Invoke(this, new OutputDataReceivedEventArgs("Waiting for IBGateway auto-restart"));
                if (!_ibAutomaterInitializeEvent.WaitOne(_initializationTimeout))
                {
                    TraceIbLauncherLogFile();

                    _lastStartResult = new StartResult(ErrorCode.InitializationTimeout);
                    return;
                }

                if (_isRestartInProgress)
                {
                    OutputDataReceived?.Invoke(this, new OutputDataReceivedEventArgs("IB Automater initialized."));

                    // find new IBGateway process (created by auto-restart)

                    var processName = IsWindows ? "ibgateway" : "java";

                    var process = Process.GetProcessesByName(processName).FirstOrDefault();
                    if (process == null)
                    {
                        OutputDataReceived?.Invoke(this, new OutputDataReceivedEventArgs($"IBGateway restarted process not found: {processName}"));

                        TraceIbLauncherLogFile();

                        _lastStartResult = new StartResult(ErrorCode.RestartedProcessNotFound);
                    }
                    else
                    {
                        OutputDataReceived?.Invoke(this, new OutputDataReceivedEventArgs($"IBGateway restarted process found: Id:{process.Id} - Name:{process.ProcessName}"));

                        // fire Restarted event so the client can reconnect only (without starting IBGateway)
                        Restarted?.Invoke(this, new EventArgs());

                        process.Exited -= OnProcessExited;

                        // replace process
                        _process = process;

                        // we cannot add output/error redirection event handlers here as we didn't start the process

                        process.Exited += OnProcessExited;
                        process.EnableRaisingEvents = true;
                    }

                    _isRestartInProgress = false;
                }
                else
                {
                    Exited?.Invoke(this, new ExitedEventArgs(GetProcessExitCode(_process)));
                }
            }
            else
            {
                Exited?.Invoke(this, new ExitedEventArgs(GetProcessExitCode(_process)));
            }
        }
 internal void OnRestarted()
 {
     Log.Success($"Server {this.ID:00} Restarted.");
     Restarted.Invoke(this, null);
 }