Пример #1
0
        public void sendEvent(string numberEvents, string topic, string interval)
        {
            Event e;
            int   times = Int32.Parse(numberEvents);
            int   sleep = Int32.Parse(interval);
            int   i     = 0;
            int   eventNumber;

            Console.WriteLine(this.brokerUrl);
            for (i = 0; i < times; i++)
            {
                eventNumber = this.SeqNumber();
                e           = new Event(topic, "", this.name, eventNumber);

                if (isFrozen)
                {
                    FrozenEvent fe = new FrozenEvent("EVENT", e);
                    frozenEvents.Add(fe);
                    Thread.Sleep(sleep);
                }
                else
                {
                    this.broker.receivePub(this.name, e);
                    events.Add(new KeyValuePair <string, Event>(name, e));
                    Console.WriteLine("Creating Event : " + topic + e.getNumber());
                    Thread.Sleep(sleep);
                }
            }
        }
Пример #2
0
 public string unsubscribe(string topic, string URL)
 {
     lock (this) {
         if (isFrozen)
         {
             FrozenEvent fe = new FrozenEvent("UNSUB", topic, URL);
             frozenEvents.Add(fe);
             return("ACK");
         }
         //        bool isfilter = false;
         // pode eliminar o errado caso existam 2 ocorrencias , FIX ME
         Console.WriteLine("Received Unsubscribe");
         foreach (KeyValuePair <string, string> kvp in topicSubs)
         {
             if (this.typeRouting.Equals("filtering"))
             {
                 removeInterestBrokers(topic, myUrl);
                 //if (topic.Equals(kvp.Key))
                 //{
                 //    isfilter = true;
                 //    removeInterestBrokers();
                 //    break;
                 //}
             }
             if (kvp.Key.Equals(topic) && kvp.Value.Equals(URL))
             {
                 topicSubs.Remove(kvp);
                 break;
             }
         }
         return("ACK");
     }
 }
Пример #3
0
 public void addSubscriber(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW SUBSCRIPTOR", name, URL);
         frozenEvents.Add(fe);
         return;
     }
     this.subs.Add(name, URL);
     Console.WriteLine("Subscriber Added:" + name);
 }
Пример #4
0
 public void addChild(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW CHILD", name, URL);
         frozenEvents.Add(fe);
         return;
     }
     this.childs.Add(name, URL);
     Console.WriteLine("Child Added:" + name);
 }
Пример #5
0
 public void addChild(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW CHILD", name, URL);
         frozenEvents.Add(fe);
         return;
     }
     this.childs.Add(name, URL);
     Console.WriteLine("Child Added:" + name);
 }
Пример #6
0
 public void receiveEvent(string name, Event e)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("EVENT", e);
         frozenEvents.Add(fe);
         return;
     }
     this.eventsReceived.Add(new KeyValuePair <string, Event>(name, e));
     Console.WriteLine("Evento Recebido de " + e.getSender() + " sobre " + e.getTopic() + " EventNumber : " + e.getNumber());
 }
Пример #7
0
 public void addPublisher(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW PUBLISHER", name, URL);
         frozenEvents.Add(fe);
         return;
     }
     this.pubs.Add(name, URL);
     this.lastSeqNumber.Add(name, 0);
     Console.WriteLine("Pub Added:" + name);
 }
Пример #8
0
 public void addPublisher(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW PUBLISHER", name, URL);
         frozenEvents.Add(fe);
         return;
     }
     this.pubs.Add(name, URL);
     this.lastSeqNumber.Add(name,0);
     Console.WriteLine("Pub Added:" + name);
 }
Пример #9
0
        public string subscribe(string topic, string URL)
        {
            if (isFrozen)
            {
                FrozenEvent fe = new FrozenEvent("SUB", topic, URL);
                frozenEvents.Add(fe);
                return("ACK");
            }
            Console.WriteLine("Received Subscribe");
            this.topicSubs.Add(new KeyValuePair <string, string>(topic, URL));

            if (typeRouting.Equals("filtering"))
            {
                tellBrokersInterest(this.myUrl, topic);
            }
            return("ACK");
        }
Пример #10
0
 public void UnsubEvent(string topic)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("UNSUB", topic, adress);
         frozenEvents.Add(fe);
         return;
     }
     try
     {
         this.broker.unsubscribe(topic, adress);
         Console.WriteLine("Create Unsubscription on : " + topic);
     }
     catch (Exception)
     {
         Console.WriteLine("Something make bum bum");
     }
 }
Пример #11
0
    protected override void Update()
    {
        //If we've arrived, we need to set a new current input direction (the ghost can't stop)
        if (transform.position == targetGridPosition.ToVector3())
        {
            var possibleDirections = new List <IntVector2>();

            foreach (var movementDirection in movementDirections)
            {
                if (movementDirection == -currentInputDirection)
                {
                    continue;
                }

                var potentialTargetPosition = targetGridPosition + movementDirection;

                if (LevelGeneratorSystem.Grid[Mathf.Abs(potentialTargetPosition.y),
                                              Mathf.Abs(potentialTargetPosition.x)] != 1)
                {
                    possibleDirections.Add(movementDirection);
                }
            }

            if (possibleDirections.Count < 1)
            {
                possibleDirections.Add(-currentInputDirection);
            }

            //if(!possibleDirections.Any())
            //{
            //    possibleDirections.Add(-currentInputDirection);
            //}

            var direction = Random.Range(0, possibleDirections.Count);
            currentInputDirection = possibleDirections[direction];
        }

        FrozenEvent frozen = new FrozenEvent();

        base.Update();
    }
Пример #12
0
        public string receivePub(string name, Event e)
        {
            if (isFrozen)
            {
                FrozenEvent fe = new FrozenEvent("EVENT", e);
                frozenEvents.Add(fe);
                return("ACK");
            }

            Console.WriteLine("Received Publish" + "Name: " + name + "eventTopic: " + e.getTopic() + " " + e.getNumber());
            if (!(name.StartsWith("broker")))
            {
                sendToPM("PubEvent " + name + " , " + e.getSender() + " , " + e.getTopic() + " , " + e.getNumber());
            }


            propagate(e);
            sentToSub(name, e);


            return("ACK");
        }
Пример #13
0
 public void addSubscriber(string name, string URL)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("NEW SUBSCRIPTOR",name,URL);
         frozenEvents.Add(fe);
         return;
     }
     this.subs.Add(name, URL);
     Console.WriteLine("Subscriber Added:" + name);
 }
Пример #14
0
        public void sendEvent(string numberEvents, string topic, string interval)
        {
            Event e;
            int times = Int32.Parse(numberEvents);
            int sleep = Int32.Parse(interval);
            int i = 0;
            int eventNumber;

            Console.WriteLine(this.brokerUrl);
            for (i = 0; i < times; i++)
            {
                eventNumber = this.SeqNumber();
                e = new Event(topic, "",this.name, eventNumber);

                if (isFrozen)
                {
                    FrozenEvent fe = new FrozenEvent("EVENT", e);
                    frozenEvents.Add(fe);
                    Thread.Sleep(sleep);
                }
                else
                {

                    this.broker.receivePub(this.name, e);
                    events.Add(new KeyValuePair<string, Event>(name, e));
                    Console.WriteLine("Creating Event : " + topic + e.getNumber());
                    Thread.Sleep(sleep);
                }
            }
        }
Пример #15
0
 public void UnsubEvent(string topic)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("UNSUB", topic, adress);
         frozenEvents.Add(fe);
         return;
     }
     try
     {
         this.broker.unsubscribe(topic, adress);
         Console.WriteLine("Create Unsubscription on : " + topic);
     }
     catch (Exception)
     {
         Console.WriteLine("Something make bum bum");
     }
 }
Пример #16
0
        public string unsubscribe(string topic, string URL)
        {
            lock (this) {
                if (isFrozen)
                {
                    FrozenEvent fe = new FrozenEvent("UNSUB", topic, URL);
                    frozenEvents.Add(fe);
                    return "ACK";
                }
            //        bool isfilter = false;
                // pode eliminar o errado caso existam 2 ocorrencias , FIX ME
                Console.WriteLine("Received Unsubscribe");
                foreach(KeyValuePair<string,string>  kvp in topicSubs)
                {

                    if (this.typeRouting.Equals("filtering"))
                    {
                        removeInterestBrokers(topic,myUrl);
                        //if (topic.Equals(kvp.Key))
                        //{
                        //    isfilter = true;
                        //    removeInterestBrokers();
                        //    break;
                        //}
                    }
                    if (kvp.Key.Equals(topic) && kvp.Value.Equals(URL))
                    {
                         topicSubs.Remove(kvp);
                         break;
                    }

                }
                return "ACK";
            }
        }
Пример #17
0
        public string subscribe(string topic, string URL)
        {
            if (isFrozen)
            {
                FrozenEvent fe = new FrozenEvent("SUB", topic, URL);
                frozenEvents.Add(fe);
                return "ACK";
            }
            Console.WriteLine("Received Subscribe");
            this.topicSubs.Add(new KeyValuePair<string,string>(topic, URL));

            if (typeRouting.Equals("filtering"))
            {
                tellBrokersInterest(this.myUrl,topic);
            }
            return "ACK";
        }
Пример #18
0
        public string receivePub(string name, Event e)
        {
            if (isFrozen)
            {
                FrozenEvent fe = new FrozenEvent("EVENT",e);
                frozenEvents.Add(fe);
                return "ACK";
            }

            Console.WriteLine("Received Publish" + "Name: " + name + "eventTopic: " + e.getTopic() + " " + e.getNumber());
            if (!(name.StartsWith("broker")))
            {
                sendToPM("PubEvent " + name + " , " + e.getSender() + " , " + e.getTopic() + " , " + e.getNumber());
            }

               propagate(e);
               sentToSub(name, e);

            return "ACK";
        }
Пример #19
0
 public void receiveEvent(string name, Event e)
 {
     if (isFrozen)
     {
         FrozenEvent fe = new FrozenEvent("EVENT", e);
         frozenEvents.Add(fe);
         return;
     }
     this.eventsReceived.Add(new KeyValuePair<string, Event>(name, e));
     Console.WriteLine("Evento Recebido de "+e.getSender()+" sobre " + e.getTopic()+" EventNumber : "+e.getNumber());
 }