public object Handle(PingMessage message) { ConsoleWriter.Write(ConsoleColor.Cyan, "Got a ping with name: " + message.Name); var response = new PongMessage { Name = message.Name }; return(Respond.With(response).ToSender()); }
public Response Handle(PingMessage message) { ConsoleWriter.Write(ConsoleColor.Cyan, "Got a ping with name: " + message.Name); var response = new PongMessage { Name = message.Name }; // Don't know if you'd use this very often, // but this is a special syntax that will send // the "response" back to the original sender return(Respond.With(response).ToSender()); }
// Simple message handler for the PingMessage message type public static Task Handle( // The first argument is assumed to be the message type PingMessage message, // Jasper supports method injection similar to ASP.Net Core MVC // In this case though, IMessageContext is scoped to the message // being handled IMessageContext context) { ConsoleWriter.Write(ConsoleColor.Blue, $"Got ping #{message.Number}"); var response = new PongMessage { Number = message.Number }; // This usage will send the response message // back to the original sender. Jasper uses message // headers to embed the reply address for exactly // this use case return(context.RespondToSender(response)); }