本文整理汇总了C#中NetMQ.NetMQSocketEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# NetMQSocketEventArgs类的具体用法?C# NetMQSocketEventArgs怎么用?C# NetMQSocketEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetMQSocketEventArgs类属于NetMQ命名空间,在下文中一共展示了NetMQSocketEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FrontendOnReceiveReady
private static void FrontendOnReceiveReady(object sender, NetMQSocketEventArgs socket)
{
// Now get next client request, route to next worker
// Dequeue and drop the next worker address
// Now get next client request, route to LRU worker
// Client request is [address][empty][request]
byte[] clientAddr = socket.Socket.Receive();
byte[] empty = socket.Socket.Receive();
byte[] request = socket.Socket.Receive();
byte[] deq;
try
{
deq = workerQueue.Dequeue();
backend.SendMore(deq);
backend.SendMore(Encoding.Unicode.GetBytes(""));
backend.SendMore(clientAddr);
backend.SendMore(Encoding.Unicode.GetBytes(""));
backend.Send(request);
}
catch (Exception exc)
{
Console.WriteLine("Q: [FrontendOnReceiveReady] Dequeue exc: {0}", exc.ToString());
}
}
示例2: RepSocketOnReceiveReady
private void RepSocketOnReceiveReady(object sender, NetMQSocketEventArgs netMqSocketEventArgs)
{
netMqSocketEventArgs.Socket.Receive();
var quotes = market.Select(pair => string.Format("{0}={1}", pair.Key, pair.Value));
var data = string.Join(";", quotes);
netMqSocketEventArgs.Socket.Send(data);
}
示例3: OnReceiveMessage
private void OnReceiveMessage(object sender, NetMQSocketEventArgs e)
{
var message = e.Socket.ReceiveMultipartMessage();
var connectionId = e.Socket is RouterSocket && message.FrameCount > 1 ? message.First.ToByteArray() : null;
var segment = new ArraySegment<byte>(message.Last.Buffer, 0, message.Last.MessageSize);
Received.Invoke(this, new DataReceivedArgs { Data = segment, SessionID = connectionId });
}
示例4: ClientOnReceiveReady
private const int REQUEST_TIMEOUT = 1000; // ms
#endregion Fields
#region Methods
private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs e)
{
bool hasMore = true;
var reply = e.Socket.ReceiveString(out hasMore);
Console.WriteLine("Server replied ({0})", reply);
}
示例5: OnPipeReady
private void OnPipeReady(object sender, NetMQSocketEventArgs e)
{
var message = e.Socket.ReceiveMultipartMessage();
var command = message.Pop().ConvertToString();
switch (command)
{
case ShoutCommand:
{
_zre.Shout("GLOBAL", message.Pop().ConvertToString());
}
break;
case InterfaceCommand:
{
_zre.SetInterface(message.Pop().ConvertToString());
}
break;
case StartCommand:
{
_zre.SetVerbose();
_zre.SetHeader("X-TYPE", "CHAT");
_zre.SetHeader("X-PID", Process.GetCurrentProcess().Id.ToString());
_zre.Start();
_zre.Join("GLOBAL");
}
break;
}
}
示例6: BackendOnReceiveReady
private static void BackendOnReceiveReady(object sender, NetMQSocketEventArgs socket)
{
// Queue worker address for LRU routing
byte[] workerAddress = socket.Socket.Receive();
// Use worker address for LRU routing
workerQueue.Enqueue(workerAddress);
// Second frame is empty
byte[] empty = socket.Socket.Receive();
// Third frame is READY or else a client reply address
byte[] clientAddress = socket.Socket.Receive();
// If client reply, send rest back to frontend
// Forward message to client if it's not a READY
if (Encoding.Unicode.GetString(clientAddress) != LRU_READY)
{
empty = socket.Socket.Receive();
byte[] reply = socket.Socket.Receive();
frontend.SendMore(clientAddress);
frontend.SendMore("");
frontend.Send(reply);
}
}
示例7: OnShimReady
private void OnShimReady(object sender, NetMQSocketEventArgs e)
{
string command = e.Socket.ReceiveFrameString();
if (command == NetMQActor.EndShimMessage)
{
m_poller.Stop();
}
}
示例8: SubscribeSocketOnReceiveReady
private void SubscribeSocketOnReceiveReady(object sender, NetMQSocketEventArgs args)
{
NetMQMessage message = args.Socket.ReceiveMessage();
if (message.FrameCount >= 2)
{
MessageReceived.Invoke(this, new MessageEventArgs(message[0].ConvertToString(), message[1].ConvertToString()));
}
}
示例9: SubSocketOnReceiveReady
private static void SubSocketOnReceiveReady(object sender, NetMQSocketEventArgs args)
{
NetMQMessage message = args.Socket.ReceiveMessage();
Console.WriteLine("Message Received:");
foreach (NetMQFrame frame in message)
{
Console.WriteLine("\t{0}", frame.ConvertToString());
}
}
示例10: WorkerOnReceiveReady
private static void WorkerOnReceiveReady(object sender, NetMQSocketEventArgs socket)
{
// Read and save all frames until we get an empty frame
// In this example there is only 1 but it could be more
byte[] address = worker.Receive();
byte[] empty = worker.Receive();
byte[] request = worker.Receive();
worker.SendMore(address);
worker.SendMore(Encoding.Unicode.GetBytes(""));
worker.Send(Encoding.Unicode.GetBytes(Encoding.Unicode.GetString(request) + " WORLD!"));
}
示例11: ClientOnReceiveReady
private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs socket)
{
var reply = socket.Socket.Receive();
if (Encoding.Unicode.GetString(reply) == (_strSequenceSent + " WORLD!"))
{
Console.WriteLine("C: Server replied OK ({0})", Encoding.Unicode.GetString(reply));
_retriesLeft = REQUEST_RETRIES;
_expectReply = false;
}
else
{
Console.WriteLine("C: Malformed reply from server: {0}", Encoding.Unicode.GetString(reply));
}
}
示例12: ClientOnReceiveReady
private static void ClientOnReceiveReady(object sender, NetMQSocketEventArgs netMqSocketEventArgs)
{
var reply = netMqSocketEventArgs.Socket.Receive();
string strReply = Encoding.Unicode.GetString(reply);
if (Int32.Parse(strReply) == _sequence)
{
Console.WriteLine("C: Server replied OK ({0})", strReply);
_retriesLeft = REQUEST_RETRIES;
_expectReply = false;
}
else
{
Console.WriteLine("C: Malformed reply from server: {0}", strReply);
}
}
示例13: OnShimMessage
private void OnShimMessage(object sender, NetMQSocketEventArgs e)
{
string command = e.Socket.ReceiveFrameString();
if (command == PublishMessageCommand)
{
// just forward the message to the publisher
NetMQMessage message = e.Socket.ReceiveMultipartMessage();
m_publisherSocket.SendMultipartMessage(message);
}
else if (command == NetMQActor.EndShimMessage)
{
// we got dispose command, we just stop the poller
m_poller.Cancel();
}
}
示例14: FrontendHandler
protected override void FrontendHandler(object sender, NetMQSocketEventArgs args)
{
bool more;
do
{
var data = args.Socket.Receive(out more);
if (more)
this.BackendSocket.SendMore(data);
else
{
this.BackendSocket.Send(data);
}
} while (more);
}
示例15: SocketReceiveReady
private void SocketReceiveReady(object sender, NetMQSocketEventArgs e)
{
var ba = e.Socket.ReceiveMultipartMessage();
if (ba != null)
{
using (var ms = new MemoryStream())
{
ms.Write(ba[2].ToByteArray(), 0, ba[2].MessageSize);
ms.Position = 0;
var data = (ProcessedEventArgs)_formatter.Deserialize(ms);
_logger.Trace("Brocker received result queue {0}", data.QueueId);
OnFramesProcessed(data);
}
}
else
{
_logger.Trace("Brocker not received");
}
}