static void Main(string[] args) { _manager = new StitchMessageManager(args); try { _manager.Start(); string groupName = _manager.CrossStitchParameters.ApplicationGroupName; while (true) { var msg = _manager.GetNextMessage(); if (msg == null) { continue; } // When we receive a message "B", log it if (msg.Data == "A") { _manager.Send(FromStitchMessage.Respond(msg, "B")); } // Else, log that we've gotten something unexpected else { _manager.SendLogs(new[] { "Unknown data " + msg.Data }); } } } catch (Exception e) { _manager.SendLogs(new[] { e.ToString() }); } }
static void Main(string[] args) { _manager = new StitchMessageManager(args); try { _manager.Start(); while (true) { var msg = _manager.GetNextMessage(); if (msg == null) { continue; } if (msg.Data == "ping?") { Thread.Sleep(5000); _manager.Send(FromStitchMessage.Respond(msg, "pong!")); } else { _manager.SendLogs(new[] { "Unknown data " + msg.Data }); } } } catch (Exception e) { Log(e.ToString()); } }
static void Main(string[] args) { _manager = new StitchMessageManager(args); try { _manager.Start(); Thread.Sleep(5000); // Start the chain by sending a ping to the entire group string groupName = _manager.CrossStitchArguments[Arguments.Application]; _manager.Send(FromStitchMessage.ToGroupData(groupName, "ping?")); while (true) { var msg = _manager.GetNextMessage(); if (msg == null) { continue; } if (msg.Data == "pong!") { Thread.Sleep(5000); _manager.Send(FromStitchMessage.Respond(msg, "ping?")); } else { _manager.SendLogs(new[] { "Unknown data " + msg.Data }); } } } catch (Exception e) { Log(e.ToString()); } }
static void Main(string[] args) { _manager = new StitchMessageManager(args); _manager.ReceiveHeartbeats = true; try { _manager.Start(); string groupName = _manager.CrossStitchParameters.ApplicationGroupName; while (true) { var msg = _manager.GetNextMessage(); if (msg == null) { continue; } // When we receive a heartbeat, broadcast a message to all stitches in the application group if (msg.IsHeartbeatMessage()) { _manager.SyncHeartbeat(msg.Id); _manager.Send(FromStitchMessage.ToGroupData(groupName, "A")); } // When we receive a message "B", log it else if (msg.Data == "B") { _manager.SendLogs(new[] { "Received B" }); } // Else, log that we've gotten something unexpected else { _manager.SendLogs(new[] { "Unknown data " + msg.Data }); } } } catch (Exception e) { _manager.SendLogs(new[] { e.ToString() }); } }