當前位置: 首頁>>代碼示例>>C#>>正文


C# ClientMessage類代碼示例

本文整理匯總了C#中ClientMessage的典型用法代碼示例。如果您正苦於以下問題:C# ClientMessage類的具體用法?C# ClientMessage怎麽用?C# ClientMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClientMessage類屬於命名空間,在下文中一共展示了ClientMessage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ToAllEventsForwardFeed

        public static FeedElement ToAllEventsForwardFeed(ClientMessage.ReadAllEventsForwardCompleted msg, Uri requestedUrl, EmbedLevel embedContent)
        {
            var self = HostName.Combine(requestedUrl, "/streams/{0}", AllEscaped);
            var feed = new FeedElement();
            feed.SetTitle("All events");
            feed.SetId(self);
            feed.SetUpdated(msg.Events.Length > 0 ? msg.Events[msg.Events.Length - 1].Event.TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);

            feed.AddLink("self", self);
            feed.AddLink("first", HostName.Combine(requestedUrl, "/streams/{0}/head/backward/{1}", AllEscaped, msg.MaxCount));
            if (msg.CurrentPos.CommitPosition != 0)
            {
                feed.AddLink("last", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", AllEscaped, new TFPos(0, 0).AsString(), msg.MaxCount));
                feed.AddLink("next", HostName.Combine(requestedUrl, "/streams/{0}/{1}/backward/{2}", AllEscaped, msg.PrevPos.AsString(), msg.MaxCount));
            }
            if (!msg.IsEndOfStream || msg.Events.Length > 0)
                feed.AddLink("previous", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", AllEscaped, msg.NextPos.AsString(), msg.MaxCount));
            feed.AddLink("metadata", HostName.Combine(requestedUrl, "/streams/{0}/metadata", AllEscaped));
            for (int i = msg.Events.Length - 1; i >= 0; --i)
            {
                feed.AddEntry(
                    ToEntry(
                        new ResolvedEvent(msg.Events[i].Event, msg.Events[i].Link, msg.Events[i].ResolveResult),
                        requestedUrl, embedContent));
            }
            return feed;
        }
開發者ID:Kristinn-Stefansson,項目名稱:EventStore,代碼行數:28,代碼來源:Convert.cs

示例2: ToStreamEventBackwardFeed

        public static FeedElement ToStreamEventBackwardFeed(ClientMessage.ReadStreamEventsBackwardCompleted msg, Uri requestedUrl, EmbedLevel embedContent, bool headOfStream)
        {
            Ensure.NotNull(msg, "msg");

            string escapedStreamId = Uri.EscapeDataString(msg.EventStreamId);
            var self = HostName.Combine(requestedUrl, "/streams/{0}", escapedStreamId);
            var feed = new FeedElement();
            feed.SetTitle(string.Format("Event stream '{0}'", msg.EventStreamId));
            feed.StreamId = msg.EventStreamId;
            feed.SetId(self);
            feed.SetUpdated(msg.Events.Length > 0 ? msg.Events[0].Event.TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);

            var prevEventNumber = Math.Min(msg.FromEventNumber, msg.LastEventNumber) + 1;
            var nextEventNumber = msg.FromEventNumber - msg.MaxCount;

            feed.AddLink("self", self);
            feed.AddLink("first", HostName.Combine(requestedUrl, "/streams/{0}/head/backward/{1}", escapedStreamId, msg.MaxCount));
            if (!msg.IsEndOfStream)
            {
                if (nextEventNumber < 0) throw new Exception(string.Format("nextEventNumber is negative: {0} while IsEndOfStream", nextEventNumber));
                feed.AddLink("last", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", escapedStreamId, 0, msg.MaxCount));
                feed.AddLink("next", HostName.Combine(requestedUrl, "/streams/{0}/{1}/backward/{2}", escapedStreamId, nextEventNumber, msg.MaxCount));
            }
            feed.AddLink("previous", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", escapedStreamId, prevEventNumber, msg.MaxCount));
            feed.AddLink("metadata", HostName.Combine(requestedUrl, "/streams/{0}/metadata", escapedStreamId));
            for (int i = 0; i < msg.Events.Length; ++i)
            {
                feed.AddEntry(ToEntry(msg.Events[i], requestedUrl, embedContent));
            }

            return feed;
        }
開發者ID:jjvdangelo,項目名稱:EventStore,代碼行數:33,代碼來源:Convert.cs

示例3: HandlePacket

        public static void HandlePacket(GameClientMessageHandler handler, ClientMessage message)
        {
            Console.ForegroundColor = ConsoleColor.DarkCyan;

            if (Incoming.ContainsKey(message.Id))
            {
                if (AzureEmulator.DebugMode)
                {
                    Console.WriteLine();
                    Console.Write("INCOMING ");
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Write("HANDLED ");
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.Write(message.Id + Environment.NewLine + message);
                    if (message.Length > 0)
                        Console.WriteLine();
                    Console.WriteLine();
                }

                StaticRequestHandler staticRequestHandler = Incoming[message.Id];
                staticRequestHandler(handler);
            }
            else if (AzureEmulator.DebugMode)
            {
                Console.WriteLine();
                Console.Write("INCOMING ");
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.Write("REFUSED ");
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write(message.Id + Environment.NewLine + message);
                if (message.Length > 0)
                    Console.WriteLine();
                Console.WriteLine();
            }
        }
開發者ID:BjkGkh,項目名稱:Azure2,代碼行數:35,代碼來源:LibraryParser.cs

示例4: Handle

        public override void Handle(ClientMessage.ReadAllEventsForwardCompleted message)
        {
            if (_disposed)
                return;
            if (!_eventsRequested)
                throw new InvalidOperationException("Read events has not been requested");
            if (_paused)
                throw new InvalidOperationException("Paused");
            _eventsRequested = false;

            if (message.Result.Records.Length == 0)
            {
                // the end
                if (_deliverEndOfTfPosition)
                    DeliverLastCommitPosition(_from);
                // allow joining heading distribution
            }
            else
            {
                for (int index = 0; index < message.Result.Records.Length; index++)
                {
                    var @event = message.Result.Records[index];
                    DeliverEvent(@event, message.Result.TfEofPosition);
                }
                _from = message.Result.NextPos;
            }

            if (_pauseRequested)
                _paused = true;
            else if (message.Result.Records.Length == 0)
                RequestEvents(delay: true);
            else
                _publisher.Publish(CreateTickMessage());
        }
開發者ID:robashton,項目名稱:EventStore,代碼行數:34,代碼來源:TransactionFileReaderEventDistributionPoint.cs

示例5: Encode

 public static void Encode(SimpleEntryView<IData, IData> dataEntryView, ClientMessage clientMessage)
 {
     var key = dataEntryView.GetKey();
     var value = dataEntryView.GetValue();
     var cost = dataEntryView.GetCost();
     var creationTime = dataEntryView.GetCreationTime();
     var expirationTime = dataEntryView.GetExpirationTime();
     var hits = dataEntryView.GetHits();
     var lastAccessTime = dataEntryView.GetLastAccessTime();
     var lastStoredTime = dataEntryView.GetLastStoredTime();
     var lastUpdateTime = dataEntryView.GetLastUpdateTime();
     var version = dataEntryView.GetVersion();
     var ttl = dataEntryView.GetTtl();
     var evictionCriteriaNumber = dataEntryView.GetEvictionCriteriaNumber();
     clientMessage.Set(key)
         .Set(value)
         .Set(cost)
         .Set(creationTime)
         .Set(expirationTime)
         .Set(hits)
         .Set(lastAccessTime)
         .Set(lastStoredTime)
         .Set(lastUpdateTime)
         .Set(version)
         .Set(evictionCriteriaNumber)
         .Set(ttl);
 }
開發者ID:hasancelik,項目名稱:hazelcast-csharp-client,代碼行數:27,代碼來源:EntryViewCodec.cs

示例6: OnLoadStateReadRequestCompleted

        private void OnLoadStateReadRequestCompleted(ClientMessage.ReadStreamEventsBackwardCompleted message)
        {
            if (message.Events.Length > 0)
            {
                var checkpoint = message.Events.Where(v => v.Event.EventType == ProjectionEventTypes.ProjectionCheckpoint).Select(x => x.Event).FirstOrDefault();
                if (checkpoint != null)
                {
                    var parsed = checkpoint.Metadata.ParseCheckpointTagVersionExtraJson(_projectionVersion);
                    if (parsed.Version.ProjectionId != _projectionVersion.ProjectionId
                        || _projectionVersion.Epoch > parsed.Version.Version)
                    {
                        _lastWrittenCheckpointEventNumber = checkpoint.EventNumber;
                        CheckpointLoaded(null, null);
                    }
                    else
                    {
                        //TODO: check epoch and correctly set _lastWrittenCheckpointEventNumber
                        var checkpointData = Helper.UTF8NoBom.GetString(checkpoint.Data);
                        _lastWrittenCheckpointEventNumber = checkpoint.EventNumber;
                        var adjustedTag = parsed.Tag; // the same projection and epoch, handle upgrades internally
                        CheckpointLoaded(adjustedTag, checkpointData);
                    }
                    return;
                }
            }

            if (message.NextEventNumber != -1)
            {
                _nextStateIndexToRequest = message.NextEventNumber;
                RequestLoadState();
                return;
            }
            _lastWrittenCheckpointEventNumber = message.LastEventNumber;
            CheckpointLoaded(null, null);
        }
開發者ID:EventStore,項目名稱:EventStore,代碼行數:35,代碼來源:CoreProjectionCheckpointReader.cs

示例7: ObjectCallback

 internal static void ObjectCallback(ClientMessage message)
 {
     lock (freeObjects.SyncRoot)
     {
         freeObjects.Enqueue(message);
     }
 }
開發者ID:habb0,項目名稱:Bfly,代碼行數:7,代碼來源:ClientMessageFactory.cs

示例8: StreamEventsSlice

        internal StreamEventsSlice(SliceReadStatus status, 
                                   string stream, 
                                   int fromEventNumber, 
                                   ReadDirection readDirection,
                                   ClientMessage.ResolvedIndexedEvent[] events,
                                   int nextEventNumber,
                                   int lastEventNumber,
                                   bool isEndOfStream)
        {
            Ensure.NotNullOrEmpty(stream, "stream");

            Status = status;
            Stream = stream;
            FromEventNumber = fromEventNumber;
            ReadDirection = readDirection;
            if (events == null || events.Length == 0)
                Events = Empty.ResolvedEvents;
            else
            {
                Events = new ResolvedEvent[events.Length];
                for (int i = 0; i < Events.Length; ++i)
                {
                    Events[i] = new ResolvedEvent(events[i]);
                }
            }
            NextEventNumber = nextEventNumber;
            LastEventNumber = lastEventNumber;
            IsEndOfStream = isEndOfStream;
        }
開發者ID:thinkbeforecoding,項目名稱:EventStore,代碼行數:29,代碼來源:StreamEventsSlice.cs

示例9: ToStreamEventForwardFeed

        public static FeedElement ToStreamEventForwardFeed(ClientMessage.ReadStreamEventsForwardCompleted msg, Uri requestedUrl, EmbedLevel embedContent)
        {
            Ensure.NotNull(msg, "msg");

            string escapedStreamId = Uri.EscapeDataString(msg.EventStreamId);
            var self = HostName.Combine(requestedUrl, "/streams/{0}", escapedStreamId);
            var feed = new FeedElement();
            feed.SetTitle(string.Format("Event stream '{0}'", msg.EventStreamId));
            feed.StreamId = msg.EventStreamId;
            feed.SetId(self);
            feed.SetUpdated(msg.Events.Length > 0 && msg.Events[0].Event != null ? msg.Events[0].Event.TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);
            feed.SetHeadOfStream(msg.IsEndOfStream);

            var prevEventNumber = Math.Min(msg.FromEventNumber + msg.MaxCount - 1, msg.LastEventNumber) + 1;
            var nextEventNumber = msg.FromEventNumber - 1;

            feed.AddLink("self", self);
            feed.AddLink("first", HostName.Combine(requestedUrl, "/streams/{0}/head/backward/{1}", escapedStreamId, msg.MaxCount));
            if (nextEventNumber >= 0)
            {
                feed.AddLink("last", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", escapedStreamId, 0, msg.MaxCount));
                feed.AddLink("next", HostName.Combine(requestedUrl, "/streams/{0}/{1}/backward/{2}", escapedStreamId, nextEventNumber, msg.MaxCount));
            }
            if (!msg.IsEndOfStream || msg.Events.Length > 0)
                feed.AddLink("previous", HostName.Combine(requestedUrl, "/streams/{0}/{1}/forward/{2}", escapedStreamId, prevEventNumber, msg.MaxCount));
            if (!escapedStreamId.StartsWith("$$"))
                feed.AddLink("metadata", HostName.Combine(requestedUrl, "/streams/{0}/metadata", escapedStreamId));
            for (int i = msg.Events.Length - 1; i >= 0; --i)
            {
                feed.AddEntry(ToEntry(msg.Events[i], requestedUrl, embedContent));
            }

            return feed;
        }
開發者ID:EventStore,項目名稱:EventStore,代碼行數:35,代碼來源:Convert.cs

示例10: process

 public override void process(ClientMessage message, Transceiver connection)
 {
     if(message.type == "newUser")
     {
         this.RequestKey(message.Get("username"));
     }
 }
開發者ID:spox,項目名稱:irisim,代碼行數:7,代碼來源:Cryptor.cs

示例11: ReadUsersForwardCompleted

        private void ReadUsersForwardCompleted(ClientMessage.ReadStreamEventsForwardCompleted result)
        {
            if (_aborted)
                return;
            switch (result.Result)
            {
                case ReadStreamResult.Success:
                    if (!result.IsEndOfStream)
                        BeginReadForward(result.NextEventNumber);

                    foreach (var loginName in from eventData in result.Events
                                              let @event = eventData.Event
                                              where @event.EventType == UserEventType
                                              let stringData = Helper.UTF8NoBom.GetString(@event.Data)
                                              select stringData)
                        BeginReadUserDetails(loginName);

                    break;
                case ReadStreamResult.NoStream:
                    Abort(UserManagementMessage.Error.NotFound);
                    break;
                default:
                    Abort(UserManagementMessage.Error.Error);
                    break;
            }
            _activeRequests--;
            TryComplete();
        }
開發者ID:czcz1024,項目名稱:EventStore,代碼行數:28,代碼來源:AllUsersReader.cs

示例12: SmartFormat

        public static string SmartFormat(ClientMessage.ReadEventCompleted completed, ICodec targetCodec)
        {
            var dto = new HttpClientMessageDto.ReadEventCompletedText(completed);
            if (completed.Record.Event.Flags.HasFlag(PrepareFlags.IsJson))
            {
                var deserializedData = Codec.Json.From<object>((string) dto.Data);
                var deserializedMetadata = Codec.Json.From<object>((string) dto.Metadata);

                if (deserializedData != null)
                    dto.Data = deserializedData;
                if (deserializedMetadata != null)
                    dto.Metadata = deserializedMetadata;
            }

            switch (targetCodec.ContentType)
            {
                case ContentType.Xml:
                case ContentType.ApplicationXml:
                case ContentType.Atom:
                {
                    var serializeObject = JsonConvert.SerializeObject(dto);
                    var deserializeXmlNode = JsonConvert.DeserializeXmlNode(serializeObject, "read-event-result");
                    return deserializeXmlNode.InnerXml;
                }

                default:
                    return targetCodec.To(dto);
            }
        }
開發者ID:base31,項目名稱:geteventstore_EventStore,代碼行數:29,代碼來源:AutoEventConverter.cs

示例13: HandlePacket

 internal static void HandlePacket(GameClientMessageHandler handler, ClientMessage message)
 {
     if (handlers.ContainsKey(message.Id))
     {
         StaticRequestHandler currentHandler = (StaticRequestHandler)handlers[message.Id];
         currentHandler.Invoke(handler);
     }
 }
開發者ID:habb0,項目名稱:Bfly,代碼行數:8,代碼來源:StaticClientMessageHandler.cs

示例14: GetXmlReadResult

 public static string GetXmlReadResult(ClientMessage.ReadEventCompleted completed, bool dataJson = true, bool metadataJson = true)
 {
     return string.Format(XmlReadFormat,
                          completed.Record.Event.EventStreamId,
                          completed.Record.Event.EventNumber,
                          completed.Record.Event.EventType,
                          dataJson ? XmlData : AsString(completed.Record.Event.Data),
                          metadataJson ? XmlMetadata : AsString(completed.Record.Event.Metadata));
 }
開發者ID:base31,項目名稱:geteventstore_EventStore,代碼行數:9,代碼來源:auto_convertion.cs

示例15: GetJsonReadResult

 public static string GetJsonReadResult(ClientMessage.ReadEventCompleted completed, bool dataJson = true, bool metadataJson = true)
 {
     return string.Format(JsonReadFormat,
                          WrapIntoQuotes(completed.Record.Event.EventStreamId),
                          completed.Record.Event.EventNumber,
                          WrapIntoQuotes(completed.Record.Event.EventType),
                          dataJson ? JsonData : WrapIntoQuotes(AsString(completed.Record.Event.Data)),
                          metadataJson ? JsonMetadata : WrapIntoQuotes(AsString(completed.Record.Event.Metadata)));
 }
開發者ID:base31,項目名稱:geteventstore_EventStore,代碼行數:9,代碼來源:auto_convertion.cs


注:本文中的ClientMessage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。