/// <summary> /// Control function for this class so we can gracefully startup/pause/exit the entire system /// </summary> /// <param name="socket"></param> /// <param name="revents"></param> static void ValkQueueWFStepsCTRL_PollInHandler(Socket socket, IOMultiPlex revents) { string Message = socket.Recv(Encoding.Unicode); Console.WriteLine(Message); if (Message == "GO") { Stop = false; } else if (Message == "STOP") { Stop = true; } else if (Message == "EXIT") { ValkQueueWFMessage ExitMessage = new ValkQueueWFMessage(); ExitMessage.Command = ValkQueueWFMessage.WFCommand.WFC_EXIT; QueueDBHandlerComm.Send <ValkQueueWFMessage>(ExitMessage); string mesg = QueueDBHandlerComm.Recv(Encoding.Unicode); DBHandler.Join(); Stop = true; Exit = true; } socket.Send("OK:" + Message, Encoding.Unicode); }
void client_PollInHandler(Socket socket, IOMultiPlex revents) { string postedMessage = socket.Recv(Encoding.Unicode); someText.Text = postedMessage; Console.WriteLine("Received message : {0}", postedMessage); }
void RecepcionHandShake(Socket socket, IOMultiPlex revents) { var idcliente = socket.Recv(); socket.Send(nombreServidor); MethodInvoker action=delegate { listanodos.Items.Add(Encoding.Unicode.GetString(idcliente));}; listanodos.BeginInvoke(action); }
static void ValkQueueWFSteps_PollInHandler(Socket socket, IOMultiPlex revents) { string reply = ""; ValkQueueWFMessage WFMessage = socket.Recv <ValkQueueWFMessage>(); switch (WFMessage.Command) { case ValkQueueWFMessage.WFCommand.WFC_WAIT: //great, don't do anything, probably a warning socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_LOAD: //warning, we don't handle this socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_CANPROCESS: //this will be a big one... socket.Send <ValkQueueWFMessage>(GetNextStep(WFMessage)); break; case ValkQueueWFMessage.WFCommand.WFC_ACTIVATE: //set first step to active, insert neededness WFMessage.Step.Status = "active"; QueueDBHandlerComm.Send <ValkQueueWFMessage>(WFMessage); reply = QueueDBHandlerComm.Recv(Encoding.Unicode); socket.Send("OK", Encoding.Unicode); ActiveSteps.Add(WFMessage.Step); break; case ValkQueueWFMessage.WFCommand.WFC_COMPLETE: //should also try to pick up the next step here, no reason to waste cycles WFMessage.Step.Status = "complete"; QueueDBHandlerComm.Send <ValkQueueWFMessage>(WFMessage); reply = QueueDBHandlerComm.Recv(Encoding.Unicode); HandleComplete(WFMessage.Step); ValkQueueWFMessage NewMessage = new ValkQueueWFMessage(); NewMessage.Command = ValkQueueWFMessage.WFCommand.WFC_CANPROCESS; socket.Send <ValkQueueWFMessage>(GetNextStep(NewMessage)); break; case ValkQueueWFMessage.WFCommand.WFC_EXCEPTION: break; case ValkQueueWFMessage.WFCommand.WFC_STOP: socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_SUBFLOW: socket.Send("OK", Encoding.Unicode); break; default: break; } }
private static void ReceiverPollInHandler(Socket socket, IOMultiPlex revents) { Debug.Assert(socket != null); var message = socket.Recv(); var result = InvokeJsonRpc(message); socket.Send(result); }
private void FrontendPollInHandler(Socket socket, IOMultiPlex revents) { // Process all parts of the message bool isProcessing = true; while (isProcessing) { byte[] message = socket.Recv(); backend.Send(message, socket.RcvMore ? SendRecvOpt.SNDMORE : 0); isProcessing = socket.RcvMore; } }
/// <summary> /// Create poll item for ZMQ and plain socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <param name="sysSocket">Raw Socket</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events, SysSockets.Socket sysSocket) { #if x86 || POSIX return(new PollItem(new ZMQPollItem(_ptr, sysSocket.Handle.ToInt32(), (short)events), this)); #elif x64 return(new PollItem(new ZMQPollItem(_ptr, sysSocket.Handle.ToInt64(), (short)events), this)); #endif }
private void ReceiverPollInHandler(Socket socket, IOMultiPlex revents) { // Process task int workload = Convert.ToInt32(socket.Recv(Encoding.Unicode)); // Do the work Thread.Sleep(workload); // Send results to sink sender.Send("", Encoding.Unicode); Console.WriteLine("."); Console.Clear(); }
private void BackendPollInHandler(Socket socket, IOMultiPlex revents) { // Process all parts of the message bool isProcessing = true; while (isProcessing) { byte[] message = socket.Recv(); frontend.Send(message, socket.RcvMore ? SendRecvOpt.SNDMORE : 0); isProcessing = socket.RcvMore; } }
static void ValkWFActivator_PollInHandler(Socket socket, IOMultiPlex revents) { //handle workflow instantiations ValkQueueWFMessage WFMessage = socket.Recv <ValkQueueWFMessage>(); if (WFMessage.Command == ValkQueueWFMessage.WFCommand.WFC_LOAD) { ValkWFStep NewInstance = null; //Console.WriteLine("Instance Insert Request Received: " + WFMessage.InstanceID + " " + WFMessage.InstanceKey); if (!LoadedInstances.Contains(WFMessage.InstanceID)) { LoadedInstances.Add(WFMessage.InstanceID); SortedDictionary <int, ValkWFStep> ToInsert = new SortedDictionary <int, ValkWFStep>(); dbHandler.StartWFInstance(WFMessage.InstanceID); if (LoadedActiveInstanceByType.ContainsKey(WFMessage.InstanceType)) { NewInstance = LoadedInstanceTemplates[LoadedActiveInstanceByType[WFMessage.InstanceType]].DeepClone <ValkWFStep>(); BuildInsertWFInstance(ToInsert, NewInstance, WFMessage.InstanceKey, true); //Console.WriteLine(DateTime.Now.ToLongTimeString() + ": Created New Instance: " + WFMessage.InstanceKey); } else { //error, no WF of this type found active } if (ToInsert.Count > 0) { InsertWFInstance(ToInsert); ValkQueueWFMessage QueueMessage = new ValkQueueWFMessage(); QueueMessage.InstanceID = WFMessage.InstanceID; QueueMessage.InstanceKey = WFMessage.InstanceKey; QueueMessage.InstanceType = WFMessage.InstanceType; QueueMessage.Command = ValkQueueWFMessage.WFCommand.WFC_ACTIVATE; QueueMessage.Step = NewInstance; QueueComm.Send <ValkQueueWFMessage>(QueueMessage); string reply = QueueComm.Recv(Encoding.Unicode); } socket.Send("OK", Encoding.Unicode); } else { //else don't do anything, duplicate message socket.Send("WARN-Duplicate Request", Encoding.Unicode); } } else { //log error message socket.Send("ERROR-Wrong Request Type", Encoding.Unicode); } }
public void StateMasheen(Socket socket, IOMultiPlex revents) { //if (!states.ContainsKey(currentState)) // throw new InvalidOperationException(String.Format("State {0} not declared in state machine!", currentState)); MoveOperation op; do { op = this.states[currentState].Handler(socket, revents); currentState = op.NextState; } while (op.Immediately); }
static void RecepcionRouter(Socket socket, IOMultiPlex revents) { //Repetidor(socket, dealer); var datos = socket.Recv(); Guid identidad = new Guid(datos); if (socket.RcvMore) { // //delimitador vacio socket.Recv(); var mensaje = socket.Recv(Encoding.Unicode); Console.WriteLine("Se recibio el mensaje en el router:" + mensaje); EnviarAWorker(identidad, mensaje); } }
static void Program_PollInHandler(Socket elev_socket, IOMultiPlex revents) { var msg = elev_socket.Recv(); string angle = Encoding.UTF8.GetString(msg); int elevation; if (int.TryParse(angle, out elevation)) { if (elevation < sensor.MaxElevationAngle && elevation > sensor.MinElevationAngle) { sensor.ElevationAngle = elevation; } } elev_socket.Send(Convert.ToString(sensor.ElevationAngle), Encoding.UTF8); }
private static void BusControllerPollInHandler(Socket socket, IOMultiPlex revents) { Debug.Assert(socket != null); var cmd = socket.Recv(Encoding.UTF8); if (cmd == "STOP-RPC" && s_running) { LoggerProvider.EnvironmentLogger.Info("The [STOP-RPC] command received, try to stop all RPC-Handlers"); lock (s_lockObj) { s_running = false; } } }
private static void PollInHandler(Socket socket, IOMultiPlex revents) { var reply = socket.Recv(Encoding.Unicode); if (Int32.Parse(reply) == sequence) { Console.WriteLine("Server replied OK ({0})", reply); retriesLeft = requestRetries; expectReply = false; } else { Console.WriteLine("Malformed reply from server: {0}", reply); } }
static void RecepcionDealer(Socket socket, IOMultiPlex revents) { //Repetidor(socket,router ); var datos = socket.Recv(); string mensaje = string.Empty; Guid identidad = new Guid(datos); if (socket.RcvMore) { //delimitador vacio socket.Recv(); mensaje = socket.Recv(Encoding.Unicode); Console.WriteLine("Se recibio el mensaje en el dealer:" + mensaje); } router.SendMore(datos); router.SendMore(string.Empty, Encoding.Unicode); router.Send(mensaje, Encoding.Unicode); }
/// <summary> /// Handles control messages /// </summary> /// <param name="socket"></param> /// <param name="revents"></param> static void ValkWFActivatorCTRL_PollInHandler(Socket socket, IOMultiPlex revents) { string Message = socket.Recv(Encoding.Unicode); Console.WriteLine(Message); socket.Send("OK:" + Message, Encoding.Unicode); if (Message == "GO") { Stop = false; } else if (Message == "STOP") { Stop = true; } else if (Message == "EXIT") { Stop = true; Exit = true; } }
static void ValkQueueDBHandler_PollInHandler(Socket socket, IOMultiPlex revents) { ValkQueueWFMessage WFMessage = socket.Recv <ValkQueueWFMessage>(); switch (WFMessage.Command) { case ValkQueueWFMessage.WFCommand.WFC_EXIT: socket.Send("OK", Encoding.Unicode); Exit = true; break; case ValkQueueWFMessage.WFCommand.WFC_ACTIVATE: StepsToUpdate.Add(WFMessage); socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_COMPLETE: StepsToUpdate.Add(WFMessage); socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_SKIP: StepsToUpdate.Add(WFMessage); socket.Send("OK", Encoding.Unicode); break; case ValkQueueWFMessage.WFCommand.WFC_EXCEPTION: break; case ValkQueueWFMessage.WFCommand.WFC_STOP: break; case ValkQueueWFMessage.WFCommand.WFC_SUBFLOW: break; default: break; } }
protected override void BackendHandler(Socket socket, IOMultiPlex revents) { socket.Forward(_frontend); }
protected override void FrontendHandler(Socket socket, IOMultiPlex revents) { Queue <byte[]> msgs = socket.RecvAll(); messageProcessor(msgs.Dequeue(), msgs); }
protected override void FrontendHandler(Socket socket, IOMultiPlex revents) { throw new NotImplementedException(); }
// Weather server event public static void SubscriberPollInHandler(Socket socket, IOMultiPlex revents) { socket.Recv(); Console.WriteLine("Process Weather"); }
public bool CheckEvent(IOMultiPlex revent) { return((_zmqPollItem.Revents & revent) > 0); }
private void OnRequest(Socket socket, IOMultiPlex revents) { var message = socket.RecvAll(Encoding.UTF8).ToArray(); if (message.First()!="RECALL") return; var from = Int64.Parse(message[1]); var to = message[2] == "ALL" ? Int64.MaxValue : Int64.Parse(message[2]); var ticks = LoopbackDevice.Retrieve(from, to); Send(socket, Encode(ticks)); }
/// <summary> /// Create poll item for ZMQ socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events) { return new PollItem(new ZMQPollItem(Ptr, 0, (short)events), this); }
/// <summary> /// Create poll item for ZMQ and plain socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <param name="sysSocket">Raw Socket</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events, SysSockets.Socket sysSocket) { #if x86 || POSIX return new PollItem(new ZMQPollItem(Ptr, sysSocket.Handle.ToInt32(), (short)events), this); #elif x64 return new PollItem(new ZMQPollItem(Ptr, sysSocket.Handle.ToInt64(), (short)events), this); #endif }
protected override void FrontendHandler(Socket socket, IOMultiPlex revents) { Queue<byte[]> msgs = socket.RecvAll(); messageProcessor(msgs.Dequeue(), msgs); }
protected override void FrontendHandler(Socket socket, IOMultiPlex revents) { socket.Forward(_backend); backendCounter.Increment(); }
protected abstract void BackendHandler(Socket socket, IOMultiPlex revents);
public bool CheckEvent(IOMultiPlex revent) { return(_pollItem.CheckEvent(revent)); }
static void RecibirMensaje(Socket socket, IOMultiPlex revents) { var mensaje=socket.Recv(Encoding.Unicode); socket.Send("Recibido:" +DateTime.Now.ToString(), Encoding.Unicode); Console.WriteLine("Se recibio el mensaje:"+mensaje); }
private void Handler(Socket socket, IOMultiPlex revents) { try { var id = socket.Recv(); DiscardEmptyLine(socket); var datagram = socket.RecvAll(Encoding.UTF8); var request = _formatter.DeserializeRequest(datagram); _work(request, response => socket.SendDatagram(id, _formatter.Serialize(response))); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ForegroundColor = ConsoleColor.White; } }
// Task Processing event public static void ReceiverPollInHandler(Socket socket, IOMultiPlex revents) { socket.Recv(); Console.WriteLine("Process Task"); }
private void ControllerPollInHandler(Socket socket, IOMultiPlex revents) { // Any waiting controller command acts as 'KILL' Console.WriteLine("Killed..."); killCommand = true; }
protected abstract void FrontendHandler(Socket socket, IOMultiPlex revents);
public bool CheckEvent (IOMultiPlex revent) { return (_zmqPollItem.Revents & revent) > 0; }
private void MessageReceiver_PollInHandler(Socket socket, IOMultiPlex revents) { msgReceived.OnNext(new ZMQPollerParams { socket = socket, revents = revents }); }
/// <summary> /// Create poll item for ZMQ socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events) { return(new PollItem(new ZMQPollItem(ptr, 0, (short)events), this)); }
public bool CheckEvent(IOMultiPlex revent) { return _pollItem.CheckEvent(revent); }
/// <summary> /// Create poll item for ZMQ and plain socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <param name="sysSocket">Raw Socket</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events, SysSockets.Socket sysSocket) { return(new PollItem(new ZMQPollItem(ptr, sysSocket.Handle.ToInt32(), (short)events), this)); }
/// <summary> /// Create poll item for ZMQ and plain socket listening, for the supplied events /// </summary> /// <param name="events">Listening events</param> /// <param name="sysSocket">Raw Socket</param> /// <returns>Socket Poll item</returns> public PollItem CreatePollItem(IOMultiPlex events, SysSockets.Socket sysSocket) { if (sysSocket == null) { throw new ArgumentNullException("sysSocket"); } #if x86 || POSIX return new PollItem(new ZMQPollItem(Ptr, sysSocket.Handle.ToInt32(), (short)events), this); #elif x64 return new PollItem(new ZMQPollItem(Ptr, sysSocket.Handle.ToInt64(), (short)events), this); #endif }
private void OnPost(Socket socket, IOMultiPlex revents) { var message = socket.RecvAll(Encoding.UTF8).ToArray(); if (message[0] != "POST") { _log("Bad request [" + message[0] + "]"); socket.Send("400 Bad Request", Encoding.UTF8); return; } _log("POST from " + message[1]); _sink.Publish(new Guid(message[2]), new Guid(message[3]), message[4]); socket.Send("202 ACCEPTED", Encoding.UTF8); }