public ConfirmUpdate(IMessagePayload req, bool s, int id, string msg) { originalRequest = req.GetType().ToString(); success = s; updatedId = id; errorMessage = msg; }
private void UnknownChannel(IMessagePayload messagePayload) { if (!mStarted) { Logger.Error("event module not started"); return; } var notifyMsg = messagePayload.WhatObject as EventMessage; var mgr = messagePayload.Who as EventManager; if (mgr == null || notifyMsg == null) { Logger.Error("mgr == null || notifyMsg == nul"); } else { if (!notifyMsg.From.StartsWith(ClientManagerName)) { return; } var ntf = new ClientGameEventNotify { From = notifyMsg.From, To = notifyMsg.To, EventMessageData = notifyMsg.ToBytes() }; client.GameClient.Notify(ntf); } }
public void PayloadTest(IMessagePayload payload, PayloadType expPlType) { var stream = new FastStream(); payload.Serialize(stream); Assert.Empty(stream.ToByteArray()); Assert.Equal(expPlType, payload.PayloadType); Assert.Equal(new byte[] { 0x5d, 0xf6, 0xe0, 0xe2 }, payload.GetChecksum()); }
public Message(IMessagePayload payload, string destination, string source, int ttl) { Payload = payload; DestinationAddress = destination; SourceAddress = source; PreviousHop = source; //When a new Message is created, the previous hop must be the source of the packet. Ttl = ttl; HopCount = 0; TotalPropagationDelay = 0; }
public static MessageDatabase From(IMessagePayload message) { var databaseItems = new List <MessageDatabaseItem>(); var properties = message.GetType().GetPropertiesAndFields(); foreach (var propertyInfo in properties) { CreateDatabaseItem(propertyInfo).Do(databaseItems.Add); } return(new MessageDatabase(message.GetPayloadType(), databaseItems)); }
public Task HandleMessage(IMessagePayload <IMessageData> baseMessage, JsonSerializerSettings serializerSettings) { switch (baseMessage.Type) { case MessageType.CovidNotification: { var details = baseMessage.Data as CovidNotification; return(_mailer.Send(MailFactory.Create(details.EmailAddress, details.Title, details.Message))); } default: throw new ArgumentException(); } }
private IMessagePayload ProcessRequest(IMessagePayload p) { ANWI.Messaging.Request req = p as ANWI.Messaging.Request; if (req.type != Request.Type.GetUpdateChunk) { return(null); } zipStream.Read(buffer, 0, buffer.Length); return(new ANWI.Messaging.Updater.Chunk() { data = buffer }); }
public void Send(Service serv, IMessagePayload payload, IMailbox returnTo) { if (!IsConnected(serv)) { Connect(serv); } int seq = GetSequence(); Message.Send(sockets[serv], seq, payload); if (returnTo != null) { pendingResponses.Add(seq, returnTo); } }
/// <summary> /// Initializes a new instance of <see cref="Message"/> with the given <see cref="IMessagePayload"/> /// and sets network magic based on the given <see cref="NetworkType"/>. /// </summary> /// <exception cref="ArgumentException"/> /// <exception cref="ArgumentNullException"/> /// <exception cref="ArgumentOutOfRangeException"/> /// <param name="payload">Message payload</param> /// <param name="netType">Network type</param> public Message(IMessagePayload payload, NetworkType netType) : this(netType) { if (payload is null) { throw new ArgumentNullException(nameof(payload), "Payload can not be null."); } byte[] temp = Encoding.ASCII.GetBytes(payload.PayloadType.ToString().ToLower()); if (temp.Length > CommandNameSize) { throw new ArgumentOutOfRangeException(nameof(payload.PayloadType), $"Payload name can not be longer than {CommandNameSize}."); } PayloadName = new byte[CommandNameSize]; Buffer.BlockCopy(temp, 0, PayloadName, 0, temp.Length); var stream = new FastStream(); payload.Serialize(stream); PayloadData = stream.ToByteArray(); }
public Message(MessageHeader messageHeader, IMessagePayload messagePayload) { MessageHeader = messageHeader; MessagePayload = messagePayload; }
public async Task SendMessage(IMessagePayload <IMessageData> payload) { var data = JsonConvert.SerializeObject(payload, _serializerSettings); var message = new Message(Encoding.UTF8.GetBytes(data)); await _queueClient.SendAsync(message); }
/// <summary> /// Push message constructor (for server use only) /// </summary> /// <param name="src"></param> /// <param name="data"></param> public Message(string src, IMessagePayload data) { sequence = -1; source = src; payload = data; }
private IMessagePayload ProcessCheckUpdate(IMessagePayload p) { Check check = p as Check; if (Configuration.updateDir == null) { return(new CheckResult() { updateNeeded = false }); } Dictionary <string, string> localChecksums = MD5List.GetDirectoryChecksum(Configuration.updateDir); List <string> differences = GetFileDifferences(localChecksums, check.checksums); if (differences.Count == 0) { logger.Info($"Client {GetLogIdentifier()} is up to date"); return(new CheckResult() { updateNeeded = false }); } else { string differenceString = ""; foreach (string file in differences) { differenceString += $"{file} "; } logger.Info( $"Client {GetLogIdentifier()} has the following files " + "out of date: " + differenceString); // Package up the files that don't match for the client // to request in chunks zipStream = new MemoryStream(); using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true)) { foreach (string file in differences) { archive.CreateEntryFromFile( Path.Combine(Configuration.updateDir, file), file); } archive.Dispose(); } zipStream.Position = 0; return(new CheckResult() { updateNeeded = true, updateSize = zipStream.Length }); } }
/// <summary> /// Normal message constructor /// </summary> /// <param name="seq"></param> /// <param name="data"></param> public Message(int seq, IMessagePayload data) { sequence = seq; payload = data; }
public Message() { payload = null; }
public static void Push(WebSocket sock, string source, IMessagePayload data) { Send(sock, new Message(source, data)); }
/// <summary> /// Convenience function for sending a message /// </summary> /// <param name="sock"></param> /// <param name="returnTo"></param> /// <param name="data"></param> public static void Send(WebSocket sock, int sequence, IMessagePayload data) { Send(sock, new Message(sequence, data)); }
public void Send(IMessageBusAddress destinationAddress, IMessagePayload message) { var sourceAddress = _messageSource.Address; _messageBus.Send(new Message(new MessageHeader(sourceAddress, destinationAddress), message), _correlatingSourceId); }