本文整理汇总了C#中NetMQMessage.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# NetMQMessage.Pop方法的具体用法?C# NetMQMessage.Pop怎么用?C# NetMQMessage.Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetMQMessage
的用法示例。
在下文中一共展示了NetMQMessage.Pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecryptApplicationMessage
public NetMQMessage DecryptApplicationMessage(NetMQMessage cipherMessage)
{
if (!SecureChannelReady)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.SecureChannelNotReady, "Cannot decrypt messages until the secure channel is ready");
}
if (cipherMessage == null)
{
throw new ArgumentNullException("cipherMessage is null");
}
if (cipherMessage.FrameCount < 2)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "cipher message should have at least 2 frames");
}
NetMQFrame protocolVersionFrame = cipherMessage.Pop();
NetMQFrame contentTypeFrame = cipherMessage.Pop();
if (!protocolVersionFrame.ToByteArray().SequenceEqual(m_protocolVersion))
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidProtocolVersion, "Wrong protocol version");
}
ContentType contentType = (ContentType)contentTypeFrame.Buffer[0];
if (contentType != ContentType.ApplicationData)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidContentType, "Not an applicagtion data message");
}
return m_recordLayer.DecryptMessage(ContentType.ApplicationData, cipherMessage);
}
示例2: getCommit
private CommitForStorage getCommit(NetMQMessage message)
{
var context = message.Pop().ConvertToString();
var stream = message.Pop().ConvertToString();
var expectedVersion = message.PopInt64();
var eventCount = message.PopInt32();
var events = new EventForStorage[eventCount];
for (int i = 0; i < eventCount; i++)
{
var eventId = new Guid(message.Pop().ToByteArray());
var timestamp = message.PopDateTime();
var typeKey = message.PopString();
var headers = message.PopStringOrNull();
var body = message.PopString();
//-1 to override concurrency check. Being lazy and not using a constant.
var version = expectedVersion == -1 ? -1 : expectedVersion + i;
events[i] = new EventForStorage(eventId, version, timestamp, typeKey, headers, body);
}
return new CommitForStorage(context, stream, events);
}
示例3: SetFromNetMQMessage
/// <summary>
/// Remove the three frames from the given NetMQMessage, interpreting them thusly:
/// 1. a byte with the HandshakeType, presumed here to be ClientHello,
/// 2. a byte-array containing the RandomNumber,
/// 3. a byte-array with the list of CipherSuites.
/// </summary>
/// <param name="message">a NetMQMessage - which must have 2 frames</param>
/// <exception cref="NetMQSecurityException"><see cref="NetMQSecurityErrorCode.InvalidFramesCount"/>: FrameCount must be 3.</exception>
public override void SetFromNetMQMessage(NetMQMessage message)
{
base.SetFromNetMQMessage(message);
if (message.FrameCount != 3)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
// get the random number
NetMQFrame randomNumberFrame = message.Pop();
RandomNumber = randomNumberFrame.ToByteArray();
// get the length of the cipher-suites array
NetMQFrame ciphersLengthFrame = message.Pop();
int ciphersLength = BitConverter.ToInt32(ciphersLengthFrame.Buffer, 0);
// get the cipher-suites
NetMQFrame ciphersFrame = message.Pop();
CipherSuites = new CipherSuite[ciphersLength];
for (int i = 0; i < ciphersLength; i++)
{
CipherSuites[i] = (CipherSuite)ciphersFrame.Buffer[i * 2 + 1];
}
}
示例4: Handle
public void Handle(NetMQFrame[] sender, NetMQMessage message)
{
Logger.Debug("[Queue_SubscribeHandler] Received subscribe request.");
var requestId = message.Pop();
var context = message.Pop().ConvertToString();
var queueId = message.Pop().ConvertToString();
var subscriberId = message.Pop().ConvertToString();
var filter = message.Pop().ConvertToString();
var utcStartTime = message.PopDateTime();
var allocationSize = message.PopInt32();
var allocationTimeInMilliseconds = message.PopInt32();
var subscribe = new SubscribeToQueue(context,
queueId,
subscriberId,
filter,
utcStartTime, allocationSize, allocationTimeInMilliseconds);
var queuedEvents = _storage.Subscribe(subscribe);
var events = queuedEvents.Events;
var msg = new NetMQMessage();
msg.Append(sender);
msg.AppendEmptyFrame();
msg.Append(ResProtocol.ResClient01);
msg.Append(requestId);
msg.Append(ResCommands.QueuedEvents);
msg.Append(context);
msg.Append(queueId);
msg.Append(subscriberId);
msg.Append(DateTime.UtcNow.ToNetMqFrame());
msg.Append(queuedEvents.AllocationId.ToNetMqFrame());
var count = events.Length;
msg.Append(count.ToNetMqFrame());
foreach (var e in events)
{
msg.Append(e.EventId.ToByteArray());
msg.Append(e.Stream);
msg.Append(e.Context);
msg.Append(e.Sequence.ToNetMqFrame());
msg.Append(e.Timestamp.ToNetMqFrame());
msg.Append(e.TypeKey);
msg.Append(e.Headers.ToNetMqFrame());
msg.Append(e.Body);
}
var result = new QueuedMessagesFetched(msg);
while (!_outBuffer.Offer(result))
_spin.SpinOnce();
}
示例5: ProcessMessage
public void ProcessMessage(NetMQMessage message, NetMQSocket socket)
{
if (message.FrameCount < 3)
throw new MalformedMessageReceivedException(message.FrameCount);
var sender = message.PopUntilEmptyFrame();
var protocolFrame = message.Pop();
var protocol = protocolFrame.ConvertToString();
ensureProtocol(protocol);
var command = message.Pop().ConvertToString();
_dispatcher.Dispatch(command, sender, message);
}
示例6: OnOutgoingMessage
protected override void OnOutgoingMessage(NetMQMessage message)
{
byte[] identity = message.Pop().ToByteArray();
// Each frame is a full ZMQ message with identity frame
while (message.FrameCount > 0)
{
var data = message.Pop().ToByteArray(false);
bool more = message.FrameCount > 0;
WriteOutgoing(identity, data, more);
}
}
示例7: Send
public Task Send(ArraySegment<byte> data, params object[] connectionIDs)
{
var task = new Task(() =>
{
var msg = new NetMQMessage();
if (_socket is RouterSocket)
{
msg.Append(new byte[0]);
msg.AppendEmptyFrame();
}
msg.Append(data.Count == data.Array.Length ? data.Array : data.ToArray());
if (connectionIDs.Length <= 0)
_socket.SendMultipartMessage(msg);
else
{
foreach (var connection in connectionIDs)
{
if (_socket is RouterSocket && connection is byte[])
{
msg.Pop();
msg.Push(((byte[])connection));
}
_socket.SendMultipartMessage(msg);
}
}
});
task.Start(_scheduler);
return task;
}
示例8: SetFromNetMQMessage
/// <summary>
/// Remove the three frames from the given NetMQMessage, interpreting them thusly:
/// 1. a byte with the HandshakeType,
/// 2. RandomNumber (a byte-array),
/// 3. a 2-byte array with the CipherSuite in the 2nd byte.
/// </summary>
/// <param name="message">a NetMQMessage - which must have 3 frames</param>
public override void SetFromNetMQMessage(NetMQMessage message)
{
base.SetFromNetMQMessage(message);
if (message.FrameCount != 2)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
// Get the random number
NetMQFrame randomNumberFrame = message.Pop();
RandomNumber = randomNumberFrame.ToByteArray();
// Get the cipher suite
NetMQFrame cipherSuiteFrame = message.Pop();
CipherSuite = (CipherSuite)cipherSuiteFrame.Buffer[1];
}
示例9: Handle
public void Handle(NetMQFrame[] sender, NetMQMessage message)
{
Log.Debug("[CommitHandler] Got a commit to write...");
var requestId = message.Pop();
var commit = getCommit(message);
var task = _writer.Store(commit);
var commitContinuationContext = new CommitContinuationContext(sender, commit.CommitId, requestId);
task.ContinueWith(onComplete, commitContinuationContext, TaskContinuationOptions.ExecuteSynchronously);
Log.Debug("[CommitHandler] Commit queued up...");
}
示例10: SetFromNetMQMessage
public virtual void SetFromNetMQMessage(NetMQMessage message)
{
if (message.FrameCount == 0)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
// remove the handshake type column
message.Pop();
}
示例11: Handle
public void Handle(NetMQFrame[] sender, NetMQMessage message)
{
Logger.Debug("[Query_LoadEventsByStream] Received a request.");
var requestId = message.Pop();
var context = message.Pop().ConvertToString();
var stream = message.Pop().ConvertToString();
var fromVersion = message.PopInt64();
var maxVersion = message.PopNullableInt64();
var events = _storage.LoadEventsForStream(context, stream, fromVersion, maxVersion);
var msg = new NetMQMessage();
msg.Append(sender);
msg.AppendEmptyFrame();
msg.Append(ResProtocol.ResClient01);
msg.Append(requestId);
msg.Append(ResCommands.QueryEventsByStreamResponse);
var count = events.Length;
msg.Append(count.ToNetMqFrame());
foreach (var e in events)
{
msg.Append(e.EventId.ToByteArray());
msg.Append(e.Stream);
msg.Append(e.Context);
msg.Append(e.Sequence.ToNetMqFrame());
msg.Append(e.Timestamp.ToNetMqFrame());
msg.Append(e.TypeKey);
msg.Append(e.Headers.ToNetMqFrame());
msg.Append(e.Body);
}
var result = new QueryEventsForStreamLoaded(msg);
while (!_buffer.Offer(result))
_spin.SpinOnce();
}
示例12: SetFromNetMQMessage
public override void SetFromNetMQMessage(NetMQMessage message)
{
base.SetFromNetMQMessage(message);
if (message.FrameCount != 1)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
NetMQFrame verifyDataFrame = message.Pop();
VerifyData = verifyDataFrame.ToByteArray();
}
示例13: SetFromNetMQMessage
/// <summary>
/// Remove the two frames from the given NetMQMessage, interpreting them thusly:
/// 1. a byte with the HandshakeType, assumed to be ClientKeyExchange
/// 2. a byte-array containing the EncryptedPreMasterSecret.
/// </summary>
/// <param name="message">a NetMQMessage - which must have 2 frames</param>
public override void SetFromNetMQMessage(NetMQMessage message)
{
base.SetFromNetMQMessage(message);
if (message.FrameCount != 1)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
NetMQFrame preMasterSecretFrame = message.Pop();
EncryptedPreMasterSecret = preMasterSecretFrame.ToByteArray();
}
示例14: SetFromNetMQMessage
public override void SetFromNetMQMessage(NetMQMessage message)
{
base.SetFromNetMQMessage(message);
if (message.FrameCount != 1)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "Malformed message");
}
NetMQFrame certificateFrame = message.Pop();
byte[] certificteBytes = certificateFrame.ToByteArray();
Certificate = new X509Certificate2();
Certificate.Import(certificteBytes);
}
示例15: OnIncomingMessage
protected override void OnIncomingMessage(byte[] identity, NetMQMessage message)
{
byte[] data = message.Pop().ToByteArray();
if (data.Length > 0 && (data[0] == 1 || data[0] == 0))
{
if (data[0] == 0)
{
m_subscriptions.Remove(data, 1, identity);
}
else
{
m_subscriptions.Add(data, 1, identity);
}
}
}