private static void MessageBus_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var app = Application.Current as TApplication; var args = e.Message.Deserialize <string[]>(); app.OnInstanceInvoked(args); }
private void _tickClient_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var tick = (MarketTick)ByteArrayToObject(e.Message); var tickerData = tickers.GetTickerData(tick.ticker); try { tickerData.RecentInfo.Ask = tick.ask; tickerData.RecentInfo.Bid = tick.bid; tickerData.RecentInfo.Last = tick.last; tickerData.RecentInfo.TotalVol = tick.vol; tickerData.RecentInfo.TradeVol = tick.vol; var now = DateTime.Now; var lastTickDate = now.Year * 10000 + now.Month * 100 + now.Day; var lastTickTime = now.Hour * 10000 + now.Minute * 100 + now.Second; tickerData.RecentInfo.DateChange = lastTickDate; tickerData.RecentInfo.TimeChange = lastTickTime; tickerData.RecentInfo.DateUpdate = lastTickDate; tickerData.RecentInfo.TimeUpdate = lastTickTime; DataSourceBase.NotifyRecentInfoUpdate(tickerData.Ticker, ref tickerData.RecentInfo); } catch (Exception ex) { LogAndMessage.LogMessage(MessageType.Error, ex.Message); } }
private static void _bus_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var answer = Encoding.UTF8.GetString(e.Message); _repos = answer.Split(new string[] { Environment.NewLine }, StringSplitOptions.None) .Select(s => Repository.FromString(s)) .Where(r => r != null) .OrderBy(r => r.Name) .ToArray(); _answer = answer; }
private void _messageBus_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var msg = JsonConvert.DeserializeObject <Command>(Encoding.UTF8.GetString(e.Message)); if (msg.TargetID != null && msg.TargetID != ID) { return; } MsgReceived?.Invoke(this, msg); _messages.Enqueue(msg); }
private void _tradeClient_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var trade = (MarketTrade)ByteArrayToObject(e.Message); var tickerData = tickers.GetTickerData(trade.ticker); var result = false; try { var quote = new Quotation(); lock (tickerData) { if (tickerData.Quotes != null) { tickerData.Quotes.Clear(); } var offset = DateTimeOffset.FromUnixTimeMilliseconds(trade.timestamp); quote = new Quotation { DateTime = (AmiDate)offset.LocalDateTime, Price = trade.price, High = trade.price, Low = trade.price, Open = trade.price, Volume = trade.vol }; if (tickerData.Quotes != null) { tickerData.Quotes.Merge(quote); } } result = true; } catch (Exception ex) { LogAndMessage.LogMessage(MessageType.Error, ex.Message); } finally { if (tickerData.QuoteDataStatus != QuoteDataStatus.Offline) { tickerData.QuoteDataStatus = result ? QuoteDataStatus.Online : QuoteDataStatus.Failed; } } DataSourceBase.NotifyQuotesUpdate(); }
private static void Bus_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { string message = Encoding.UTF8.GetString(e.Message); if (string.IsNullOrEmpty(message)) { return; } if (message.StartsWith("list:")) { string repositoryNamePattern = message.Substring("list:".Length); var bus = (TinyMessageBus)sender; string answer = "(no repositories found)"; try { var aggregator = TinyIoCContainer.Current.Resolve <IRepositoryInformationAggregator>(); var repos = aggregator.Repositories .Where(r => string.IsNullOrEmpty(repositoryNamePattern) || Regex.IsMatch(r.Name, repositoryNamePattern, RegexOptions.IgnoreCase)) .Select(r => $"{r.Name}|{r.BranchWithStatus}|{r.Path}") .ToArray(); if (repos.Any()) { answer = string.Join(Environment.NewLine, repos); } } catch (Exception ex) { answer = ex.Message; } bus.PublishAsync(Encoding.UTF8.GetBytes(answer)); } }
public static void DataNotificationDiagnostic(object sender, TinyMessageReceivedEventArgs e) { Debug.Print(e.Message.ToString()); }
private void InstanceBus_MessageReceived(object sender, TinyMessageReceivedEventArgs e) { var message = UnwrapMessage(e.Message); if (!message.HasValue) { return; } LogManager.Debug.Info($"Receive message - name = {message.Value.Name}, " + $"type = {message.Value.ContentType}, restoreWindow = {message.Value.RestoreWindow}"); if (message.Value.ContentType == IpcBusContentType.StringUtf8) { LogManager.Debug.Info($"Receive message content - {message.Value.GetStringUtf8()}"); } if (message.Value.Name == "SendArgs") { var args = message.Value.GetStringUtf8().Split(" || "); var wrapper = App.UnwrapArgs(args); foreach (var argEntry in wrapper.Enumerate()) { switch (argEntry.Key) { case "startupUri": var startupUri = (string)argEntry.Value; if (!string.IsNullOrEmpty(startupUri)) { ProtocolManager.ParseUri(startupUri); } break; case "createHashFiles": var createHashFilesString = (string)argEntry.Value; bool createHashFiles; try { createHashFiles = string.IsNullOrWhiteSpace(createHashFilesString) || createHashFilesString.ToBoolean(); } catch (Exception) { createHashFiles = false; } if (createHashFiles) { App.CreateHashFiles(); } break; default: break; } } } else { return; } if (message.Value.RestoreWindow) { _ = WindowNative.PostMessage((IntPtr)WindowNative.HwndBroadcast, SingleInstanceMessage, IntPtr.Zero, IntPtr.Zero); } }