Ejemplo n.º 1
0
        static void StartHandler(String sendOn, String listenOn)
        {
            SynapseEndpoint Sender = new SynapseEndpoint(sendOn);

            Sender.Connect();

            SynapseEndpoint Receiver = new SynapseEndpoint(listenOn);

            Receiver.Connect();
            new Thread(() => Receiver.ReceiveMessages(ProcessHandlerRequest, false, Sender)).Start();

            while (true)
            {
                String input = Console.ReadLine();

                String[] strs = input.Split(',');
                if (strs[0] == "STATUS")
                {
                    Sender.SendMessage(null, MessageType.STATUS, strs[1]);
                }
                else if (strs[0] == "QUERY")
                {
                    Sender.SendMessage(null, MessageType.REQUEST, strs[1]);
                }
            }
        }
Ejemplo n.º 2
0
        // Worker Functions
        static String ProcessHandlerRequest(String messageId, MessageType messageType, String message, SynapseEndpoint socket, String sendStatusTo)
        {
            if (socket != null && messageType == MessageType.REQUEST)
            {
                socket.SendMessage(messageId, MessageType.ACK, "");
                Console.WriteLine(">>> [" + messageId + "]  Request Received : " + message);
                Thread.Sleep(3000);
                socket.SendMessage(messageId, MessageType.REPLY, message.ToUpper());
            }

            return(null);
        }
Ejemplo n.º 3
0
        static String ProcessPlanStatusRequest(String messageId, MessageType messageType, String message, SynapseEndpoint socket, String sendStatusTo)
        {
            if (messageType == MessageType.REQUEST)
            {
                socket.SendMessage(messageId, MessageType.ACK, "");
                Console.WriteLine(">>> [" + messageId + "] Plan Status Request Received : " + message);
                Thread.Sleep(3000);

                Random rnd = new Random();
                int    i   = rnd.Next(1, 3);

                String reply = (i == 1?"RUNNING":"CANCELLED");
                socket.SendMessage(messageId, MessageType.REPLY, reply);
            }

            return(null);
        }
Ejemplo n.º 4
0
        static String ProcessStatus(String messageId, MessageType messageType, String message, SynapseEndpoint socket, String sendStatusTo)
        {
            if (messageType == MessageType.STATUS)
            {
                socket.SendMessage(messageId, MessageType.ACK, "");
                Console.WriteLine(">>> [" + messageId + "]  Status Received : " + message);
            }

            return(null);
        }
Ejemplo n.º 5
0
        static String ToUpperReplyToSender(String messageId, MessageType messageType, String message, SynapseEndpoint socket, String sendStatusTo)
        {
            Thread.Sleep(3000);
            if (socket != null)
            {
                for (int i = 0; i < 5; i++)
                {
                    socket.SendMessage(messageId, MessageType.STATUS, "Status Report #" + (i + 1), sendStatusTo);
                    Thread.Sleep(3000);
                }
            }

            return(message.ToUpper());
        }
Ejemplo n.º 6
0
        static void StartClient(string endpoint)
        {
            SynapseEndpoint WorkRequest = new SynapseEndpoint(endpoint);

            WorkRequest.Connect();

            new Thread(() => WorkRequest.ReceiveReplies(ProcessMyReplies)).Start();

            while (true)
            {
                String message = Console.ReadLine();
                WorkRequest.SendMessage(null, MessageType.REQUEST, message);
            }
        }
Ejemplo n.º 7
0
        static void StartApi(string sendOn, string listenOn)
        {
            SynapseEndpoint Sender = new SynapseEndpoint(sendOn);

            Sender.Connect();

            SynapseEndpoint Receiver = new SynapseEndpoint(listenOn);

            Receiver.Connect();
            new Thread(() => Receiver.ReceiveMessages(ProcessApiRequest, false, Sender)).Start();

            while (true)
            {
                String message = Console.ReadLine();
                Sender.SendMessage(null, MessageType.REQUEST, message);
            }
        }