本文整理汇总了C#中ClientMessage类的典型用法代码示例。如果您正苦于以下问题:C# ClientMessage类的具体用法?C# ClientMessage怎么用?C# ClientMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientMessage类属于命名空间,在下文中一共展示了ClientMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SendConnectionMessage
private void SendConnectionMessage(Controller controller, string username, string password, string servername, string port)
{
ClientMessage message = new ClientMessage("connect");
message.Add("server", servername);
message.Add("port", port);
message.Add("username", username);
message.Add("password", password);
controller.message_pump.process_message(message);
}
开发者ID:spox,项目名称:irisim,代码行数:9,代码来源:ConnectionStatus.cs
示例17: InvokeHandler
public static bool InvokeHandler(ref TcpClient sender, ClientMessage opcode, byte[] data)
{
if (OpcodeHandlers.ContainsKey(opcode))
{
OpcodeHandlers[opcode].Invoke(ref sender, data);
return true;
}
else
return false;
}
开发者ID:thebillkidy,项目名称:INF202A_DotNetDeel2,代码行数:10,代码来源:PacketManager.cs
示例18: InvokeHandler
public static bool InvokeHandler(ref PacketReader reader, WorldClass session, ClientMessage opcode)
{
if (OpcodeHandlers.ContainsKey(opcode))
{
OpcodeHandlers[opcode].Invoke(ref reader, ref session);
return true;
}
else
return false;
}
开发者ID:Gargash,项目名称:Arctium,代码行数:10,代码来源:PacketManager.cs
示例19: Handle
public override void Handle(ClientMessage.ReadStreamEventsForwardCompleted message)
{
if (_disposed)
return;
if (!_eventsRequested)
throw new InvalidOperationException("Read events has not been requested");
if (message.EventStreamId != _streamName)
throw new InvalidOperationException(
string.Format("Invalid stream name: {0}. Expected: {1}", message.EventStreamId, _streamName));
if (_paused)
throw new InvalidOperationException("Paused");
_eventsRequested = false;
switch (message.Result)
{
case ReadStreamResult.NoStream:
DeliverSafeJoinPosition(GetLastCommitPositionFrom(message)); // allow joining heading distribution
if (_pauseRequested)
_paused = true;
else
RequestEvents(delay: true);
SendIdle();
SendEof();
break;
case ReadStreamResult.Success:
if (message.Events.Length == 0)
{
// the end
DeliverSafeJoinPosition(GetLastCommitPositionFrom(message));
SendIdle();
SendEof();
}
else
{
for (int index = 0; index < message.Events.Length; index++)
{
var @event = message.Events[index].Event;
var @link = message.Events[index].Link;
DeliverEvent(@event, @link, 100.0f * (link ?? @event).EventNumber / message.LastEventNumber);
}
}
if (_disposed)
return;
if (_pauseRequested)
_paused = true;
else if (message.Events.Length == 0)
RequestEvents(delay: true);
else
_publisher.Publish(CreateTickMessage());
break;
default:
throw new NotSupportedException(
string.Format("ReadEvents result code was not recognized. Code: {0}", message.Result));
}
}
开发者ID:base31,项目名称:geteventstore_EventStore,代码行数:55,代码来源:StreamEventReader.cs
示例20: process_message
public void process_message(ClientMessage message)
{
try
{
this._client_event(message, this.connection);
}
catch(Exception e)
{
Logger.log("Error: No plugins loaded to process client message. (Dropping) "+e.Message+" \n"+e.StackTrace, Logger.Verbosity.moderate);
}
}
开发者ID:spox,项目名称:irisim,代码行数:11,代码来源:ClientMessagePump.cs
注:本文中的ClientMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论