Esempio n. 1
0
        private HttpContent ToHttpContent(OmfMessage msg)
        {
            ByteArrayContent content = new ByteArrayContent(msg.Body);

            foreach (var header in msg.Headers)
            {
                content.Headers.Add(header.Key, header.Value);
            }
            return(content);
        }
Esempio n. 2
0
        public async Task SendMessageAsync(byte[] body, MessageType msgType, MessageAction action)
        {
            OmfMessage omfMessage = new OmfMessage();

            omfMessage.ProducerToken = _producerToken;
            omfMessage.MessageType   = msgType;
            omfMessage.Action        = action;
            omfMessage.MessageFormat = MessageFormat.JSON;
            omfMessage.Body          = body;
            omfMessage.Version       = CurrentOmfVersion;

            if (UseCompression)
            {
                omfMessage.Compress(MessageCompression.GZip);
            }

            HttpContent         content  = ToHttpContent(omfMessage);
            HttpResponseMessage response = await _client.PostAsync("" /* use the base URI */, content);

            response.EnsureSuccessStatusCode();
        }