private void SendHeartbeatUpdate() { while (_cancellationTokenSource.IsCancellationRequested == false) { if (!SilentMode) { OnMessageUpdate?.Invoke("MESSAGE", _streamSettings.HeartbeatPattern); } Thread.Sleep(_streamSettings.HeartbeatIntervalMs); } }
private void SendMessages(int messagesPerSecond, int batchSize) { // 'MESSAGE' just sends the message to the client without filtering for a symbol int index = 0; for (int i = 0; i < messagesPerSecond; i++) { if (batchSize <= 1) { if (index >= _streamSettings.Symbols.Count) { index = 0; } var symbol = _streamSettings.Symbols[index]; OnMessageUpdate?.Invoke("MESSAGE", $"{symbol};{_xeger.Generate()}"); index++; } else { for (int j = 0; j < batchSize; j++) { if (index >= _streamSettings.Symbols.Count) { index = 0; } var symbol = _streamSettings.Symbols[index]; _batchStringBuilder.Append($"{symbol};{_xeger.Generate()}"); index++; } OnMessageUpdate?.Invoke("MESSAGE", _batchStringBuilder.ToString()); } } }