Example #1
0
 private void handleTell(KQMLMessage msg, AbstractSimpleSocket socket)
 {
     receivedMsgs.Add(msg); // is this really necessary?
     Console.WriteLine($"[SocketStringConsumer] Received tell message: {msg.ToString()}");
     //socket.Send(KQMLMessage.createTell(this.name, msg.sender, this.nextMsgId(), msg.reply_with, ":ok").ToString());
     //this.Out.Post(msg.content.ToString(), DateTime.Now); // utilize... later
 }
Example #2
0
        private void ProcessMessageFromUpstream(string data, AbstractSimpleSocket socket)
        {
            // push this into Out
            Console.WriteLine($"[SocketStringConsumer] Facilitator says: {data} - length {data.Length}");
            if (data.Length > 3)
            {
                KQMLMessage kqml = (new KQMLMessageParser()).parse(data);
                if (kqml != null && ready)
                {
                    switch (kqml.performative)
                    {
                    case "ping":
                    case "common-lisp-user::ping":
                        handlePing(kqml, socket);
                        break;

                    case "achieve":
                    case "common-lisp-user::achieve":
                        handleAchieve(kqml, socket);
                        break;

                    case "tell":
                    case "common-lisp-user::tell":
                        handleTell(kqml, socket);
                        break;

                    case "error":
                        Console.WriteLine($"[SocketStringConsumer] Error: {kqml.ToString()}");
                        break;

                    case "ask_all":
                    case "ask_one":
                    case "advertise":
                    case "untell":
                    case "subscribe":
                    default:
                        Console.WriteLine($"[SocketStringConsumer] Unknown KQML Performative: {kqml.performative}");
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine($"[SocketStringConsumer] Facilitator message ignored: {data}");
            }
        }
Example #3
0
        private void ProcessMessageFromUpstream(string data, AbstractSimpleSocket socket)
        {
            KQMLMessage msg = (new KQMLMessageParser()).parse(data);

            socket.Send(KQMLMessage.createTell(msg.receiver, msg.sender, msg.reply_with, "echoer", ":ok").ToString());

            if (msg.performative != "tell" && msg.performative != "register")
            {
                Console.WriteLine($"[Echoer] Recieved data: {data}.");// ; Parsed content: {msg.content}");
                string temp = msg.receiver;
                msg.receiver = msg.sender;
                msg.sender   = temp;

                facilitator.Connect();
                var outbound_msg = msg.ToString();
                //Console.WriteLine($"[Echoer] Outbound message: {outbound_msg}");
                facilitator.Send(outbound_msg);
                facilitator.Close();
            }
        }