public void publishEvent(string topic, int number, int interval) { for (int i = 1; i <= number; i++) { Message aux = new Message(topic, i.ToString()); broker.publish(aux); } }
//chamada pelo Publisher public void publish(Message aux) { foreach (KeyValuePair<Subscriber, string> t in lstSubsTopic) { if (aux.Topic.Equals(t.Value)) { notify(t.Key, aux); } } //if metodo de routing == flooding foreach (var viz in lstVizinhos) { floodMsg(aux, this); } }
//chamada pelos brokers private void floodMsg(Message aux, Broker broker) { foreach (KeyValuePair<Subscriber, string> t in lstSubsTopic) { if (aux.Topic.Equals(t.Value)) { notify(t.Key, aux); } } List<Broker> lst = lstVizinhos; lst.Remove(broker); //propagar para os outros todos foreach (var viz in lst) { floodMsg(aux, this); } }
private void notify(Subscriber s, Message m) { s.entregaEvento(m); }
public void notify(Message m) { Console.WriteLine("@SubNotify received a notification on topic {0} ----> {1}", m.Topic,m.Content); LogInterface log = (LogInterface)Activator.GetObject(typeof(LogInterface), "tcp://localhost:8086/PuppetMasterLog"); log.log(this.name, m.author, m.Topic, 0, "subscriber"); }
public void publish(string number, string topic, string secs,int filter, int order) { string urlRemote = url.Substring(0, url.Length - 14);//retirar XXXX/publisher string myURL = urlRemote + myPort; Console.WriteLine("@MPMPubImplementatio - {0} publishing events, on topic {1}", myURL, topic); int port = 9000; int mult = Int32.Parse("" + site[site.Length - 1]); urlRemote += (port + (mult * 100) + 1).ToString() + "/"; BrokerReceiveBroker pub = (BrokerReceiveBroker)Activator.GetObject(typeof(BrokerReceiveBroker), urlRemote + "BrokerCommunication"); for (int i = 0; i < Int32.Parse(number); i++) { count = count + 1; Message maux = new Message(topic, i.ToString(), count, name); pub.receivePublication(maux, myURL,filter,order); LogInterface log = (LogInterface)Activator.GetObject(typeof(LogInterface), "tcp://localhost:8086/PuppetMasterLog"); log.log(this.name, this.name, topic, 0, "publisher"); } }
public void entregaEvento(Message m) { Console.WriteLine("O subscriber {0} recebeu uma msg no topico {1}, com conteudo {2}", this.Name, m.Topic, m.Content); }
private void notify(string s, Message m) { //s.entregaEvento(m); }