예제 #1
0
        /// <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);
        }
예제 #3
0
 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);
 }
예제 #4
0
        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;
            }
        }
예제 #5
0
        private static void ReceiverPollInHandler(Socket socket, IOMultiPlex revents)
        {
            Debug.Assert(socket != null);

            var message = socket.Recv();
            var result  = InvokeJsonRpc(message);

            socket.Send(result);
        }
예제 #6
0
 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;
     }
 }
예제 #7
0
        /// <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
        }
예제 #8
0
        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();
        }
예제 #9
0
        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;
            }
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
 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);
     }
 }
예제 #13
0
        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);
        }
예제 #14
0
        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;
                }
            }
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
 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);
 }
예제 #17
0
        /// <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;
            }
        }
예제 #18
0
        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;
            }
        }
예제 #19
0
 protected override void BackendHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Forward(_frontend);
 }
예제 #20
0
        protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
        {
            Queue <byte[]> msgs = socket.RecvAll();

            messageProcessor(msgs.Dequeue(), msgs);
        }
예제 #21
0
 protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
 {
     throw new NotImplementedException();
 }
예제 #22
0
 // Weather server event
 public static void SubscriberPollInHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Recv();
     Console.WriteLine("Process Weather");
 }
예제 #23
0
파일: mspoller.cs 프로젝트: tzuryby/zguide
 // Weather server event
 public static void SubscriberPollInHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Recv();
     Console.WriteLine("Process Weather");
 }
예제 #24
0
 public bool CheckEvent(IOMultiPlex revent)
 {
     return((_zmqPollItem.Revents & revent) > 0);
 }
예제 #25
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));
        }
예제 #26
0
파일: Socket.cs 프로젝트: paulcbetts/clrzmq
 /// <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);
 }
예제 #27
0
파일: Socket.cs 프로젝트: abdullin/clrzmq2
 /// <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
 }
예제 #28
0
파일: Device.cs 프로젝트: rgl/clrzmq2
 protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
 {
     Queue<byte[]> msgs = socket.RecvAll();
     messageProcessor(msgs.Dequeue(), msgs);
 }
예제 #29
0
파일: Device.cs 프로젝트: rgl/clrzmq2
 protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
 {
     throw new NotImplementedException();
 }
예제 #30
0
 protected override void FrontendHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Forward(_backend);
     backendCounter.Increment();
 }
예제 #31
0
 protected abstract void BackendHandler(Socket socket, IOMultiPlex revents);
예제 #32
0
 public bool CheckEvent(IOMultiPlex revent)
 {
     return(_pollItem.CheckEvent(revent));
 }
예제 #33
0
파일: lpclient.cs 프로젝트: hnkien/zguide2
        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);
            }
        }
예제 #34
0
 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;
            }
        }
예제 #36
0
파일: mspoller.cs 프로젝트: tzuryby/zguide
 // Task Processing event
 public static void ReceiverPollInHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Recv();
     Console.WriteLine("Process Task");
 }
예제 #37
0
 private void ControllerPollInHandler(Socket socket, IOMultiPlex revents)
 {
     //  Any waiting controller command acts as 'KILL'
     Console.WriteLine("Killed...");
     killCommand = true;
 }
예제 #38
0
파일: Device.cs 프로젝트: rgl/clrzmq2
 protected abstract void FrontendHandler(Socket socket, IOMultiPlex revents);
예제 #39
0
 // Task Processing event
 public static void ReceiverPollInHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Recv();
     Console.WriteLine("Process Task");
 }
예제 #40
0
파일: Device.cs 프로젝트: rgl/clrzmq2
 protected override void BackendHandler(Socket socket, IOMultiPlex revents)
 {
     socket.Forward(_frontend);
 }
예제 #41
0
파일: Polling.cs 프로젝트: Gohla/protophase
 public bool CheckEvent (IOMultiPlex revent) {
     return (_zmqPollItem.Revents & revent) > 0;
 }
예제 #42
0
 private void MessageReceiver_PollInHandler(Socket socket, IOMultiPlex revents)
 {
     msgReceived.OnNext(new ZMQPollerParams { socket = socket, revents = revents });
 }
예제 #43
0
파일: zmq.cs 프로젝트: ssh352/quantmodel
 /// <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));
 }
예제 #44
0
파일: Socket.cs 프로젝트: paulcbetts/clrzmq
 public bool CheckEvent(IOMultiPlex revent)
 {
     return _pollItem.CheckEvent(revent);
 }
예제 #45
0
파일: zmq.cs 프로젝트: ssh352/quantmodel
 /// <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));
 }
예제 #46
0
파일: Socket.cs 프로젝트: paulcbetts/clrzmq
        /// <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
        }
예제 #47
0
 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);
 }