Esempio n. 1
0
        public void Start(Action onCompleted, ReplayDescriptor descriptor)
        {
            // start listening
            this.listener           = new SimpleSocketServer(this.localPort);
            this.listener.OnMessage = this.ProcessMessageFromUpstream; // push the data downstream
            this.listener.StartListening();

            // register with facilitator
            facilitator           = new SimpleSocket(this.facilitatorIp, facilitatorPort);
            facilitator.OnMessage = this.ProcessMessageFromUpstream;
            facilitator.Connect();

            var registermsg = $"(register :sender {this.name} :receiver facilitator :content (\"socket://127.0.0.1:{this.localPort}\" nil nil {this.localPort}))";

            facilitator.Send(registermsg);
            facilitator.Close();

            // advertise - skipped
            //string fn = "test";
            //string msgid = nextMsgId();
            //var admsg = $"(advertise :sender {this.name} :receiver facilitator :reply-with {msgid} " +
            //    $":content (ask-all :receiver {this.name} :in-reply-to {msgid} :content {fn}))";
            //facilitator.Connect();
            //facilitator.Send(admsg);
            //facilitator.Close();

            this.ready = true;
            Console.WriteLine("[SocketStringConsumer] ***Ready***\n");
        }
Esempio n. 2
0
        public SocketEchoer(string facilitatorIp = "127.0.0.1", int facilitatorPort = 9000, int localPort = 6000)
        {
            this.facilitatorIp   = facilitatorIp;
            this.facilitatorPort = facilitatorPort;
            this.localPort       = localPort;

            // start listening
            this.listener           = new SimpleSocketServer(this.localPort);
            this.listener.OnMessage = this.ProcessMessageFromUpstream; // push the data downstream
            this.listener.StartListening();

            facilitator           = new SimpleSocket(this.facilitatorIp, facilitatorPort);
            facilitator.OnMessage = this.ProcessMessageFromUpstream;

            this.ready = true;

            // register with facilitator
            //facilitator = new SimpleSocket(this.facilitatorIp, facilitatorPort);
            //facilitator.OnMessage = this.ProcessMessageFromUpstream;
            //facilitator.Connect();
            //var registermsg = $"(register :sender {this.name} :receiver facilitator :content (\"socket://127.0.0.1:{this.localPort}\" nil nil {this.localPort}))";
            //facilitator.Send(registermsg);
            //facilitator.Close();
        }