Example #1
0
        public static string ReadAllEventsForwardCompleted(HttpResponseFormatterArgs entity, Message message, EmbedLevel embed)
        {
            var msg = message as ClientMessage.ReadAllEventsForwardCompleted;

            if (msg == null || msg.Result != ReadAllResult.Success)
            {
                return(String.Empty);
            }

            return(entity.ResponseCodec.To(Convert.ToAllEventsForwardFeed(msg, entity.RequestedUrl, embed)));
        }
Example #2
0
        public static string GetFreshStatsCompleted(HttpResponseFormatterArgs entity, Message message)
        {
            var completed = message as MonitoringMessage.GetFreshStatsCompleted;

            if (completed == null || !completed.Success)
            {
                return(String.Empty);
            }

            return(entity.ResponseCodec.To(completed.Stats));
        }
Example #3
0
        public static string ReadNextNPersistentMessagesCompleted(HttpResponseFormatterArgs entity, Message message, string streamId, string groupName, int count, EmbedLevel embed)
        {
            var msg = message as ClientMessage.ReadNextNPersistentMessagesCompleted;

            if (msg == null || msg.Result != ClientMessage.ReadNextNPersistentMessagesCompleted.ReadNextNPersistentMessagesResult.Success)
            {
                return(String.Empty);
            }

            return(entity.ResponseCodec.To(Convert.ToNextNPersistentMessagesFeed(msg, entity.RequestedUrl, streamId, groupName, count, embed)));
        }
Example #4
0
        public static string GetStreamEventsBackward(HttpResponseFormatterArgs entity, Message message, EmbedLevel embed, bool headOfStream)
        {
            var msg = message as ClientMessage.ReadStreamEventsBackwardCompleted;

            if (msg == null || msg.Result != ReadStreamResult.Success)
            {
                return(String.Empty);
            }

            return(entity.ResponseCodec.To(Convert.ToStreamEventBackwardFeed(msg, entity.RequestedUrl, embed, headOfStream)));
        }
Example #5
0
        public static string GetReplicationStatsCompleted(HttpResponseFormatterArgs entity, Message message)
        {
            if (message.GetType() != typeof(ReplicationMessage.GetReplicationStatsCompleted))
            {
                throw new Exception(string.Format("Unexpected type of Response message: {0}, expected: {1}",
                                                  message.GetType().Name,
                                                  typeof(ReplicationMessage.GetReplicationStatsCompleted).Name));
            }
            var completed = message as ReplicationMessage.GetReplicationStatsCompleted;

            return(entity.ResponseCodec.To(completed.ReplicationStats));
        }
Example #6
0
        public static string SendGossip(HttpResponseFormatterArgs entity, Message message)
        {
            if (message.GetType() != typeof(GossipMessage.SendGossip))
            {
                throw new Exception(string.Format("Unexpected type of response message: {0}, expected: {1}",
                                                  message.GetType().Name,
                                                  typeof(GossipMessage.SendGossip).Name));
            }

            var sendGossip = message as GossipMessage.SendGossip;

            return(sendGossip != null
                                           ? entity.ResponseCodec.To(new ClusterInfoDto(sendGossip.ClusterInfo, sendGossip.ServerEndPoint))
                                           : string.Empty);
        }
Example #7
0
        public static string EventEntry(HttpResponseFormatterArgs entity, Message message, EmbedLevel embed)
        {
            var msg = message as ClientMessage.ReadEventCompleted;

            if (msg == null || msg.Result != ReadEventResult.Success || msg.Record.Event == null)
            {
                return(entity.ResponseCodec.To(new {}));
            }

            switch (entity.ResponseCodec.ContentType)
            {
            case ContentType.Atom:
            case ContentType.AtomJson:
            case ContentType.Html:
                return(entity.ResponseCodec.To(Convert.ToEntry(msg.Record, entity.RequestedUrl, embed, singleEntry: true)));

            default:
                return(AutoEventConverter.SmartFormat(msg.Record, entity.ResponseCodec));
            }
        }
Example #8
0
 public static string DeleteStreamCompleted(HttpResponseFormatterArgs entity, Message message)
 {
     return(String.Empty);
 }
Example #9
0
 public static string WriteEventsCompleted(HttpResponseFormatterArgs entity, Message message)
 {
     return(String.Empty);
 }
Example #10
0
 public static string GetDescriptionDocument(HttpResponseFormatterArgs entity, string streamId, string[] persistentSubscriptionStats)
 {
     return(entity.ResponseCodec.To(Convert.ToDescriptionDocument(entity.RequestedUrl, streamId, persistentSubscriptionStats)));
 }
Example #11
0
        public static string TextMessage(HttpResponseFormatterArgs entity, Message message)
        {
            var textMessage = message as HttpMessage.TextMessage;

            return(textMessage != null?entity.ResponseCodec.To(textMessage) : String.Empty);
        }