コード例 #1
0
        public void UpdateAgent(QMFObject obj)
        {
            long   agentBank  = (long)obj.GetProperty("agentBank");
            long   brokerBank = (long)obj.GetProperty("brokerBank");
            String key        = Agent.AgentKey(agentBank, brokerBank);

            if (obj.IsDeleted())
            {
                if (Agents.ContainsKey(key))
                {
                    Agent agent = Agents[key];
                    Agents.Remove(key);
                    consoleSession.HandleAgentRemoved(agent);
                }
            }
            else
            {
                if (!Agents.ContainsKey(key))
                {
                    Agent newAgent = new Agent(this, agentBank, (string)obj.GetProperty("label"));
                    Agents.Add(key, newAgent);
                    consoleSession.HandleNewAgent(newAgent);
                }
            }
        }
コード例 #2
0
        public void HandleHeartbeatIndicator(Broker broker, IDecoder decoder, long sequence, IMessage msg)
        {
            if (Console != null)
            {
                long brokerBank = 1;
                long agentBank  = 0;
                try {
                    string routingKey = msg.DeliveryProperties.GetRoutingKey();
                    if (routingKey != null)
                    {
                        agentBank  = Agent.GetBrokerBank(routingKey);
                        brokerBank = Agent.GetBrokerBank(routingKey);
                    }
                }
                catch (Exception e) {
                    log.Warn("Internal QPID error", e);
                }

                string agentKey  = Agent.AgentKey(agentBank, brokerBank);
                long   timestamp = decoder.ReadUint64();
                if (broker.Agents.ContainsKey(agentKey))
                {
                    Agent agent = broker.Agents[agentKey];
                    Console.HearbeatRecieved(agent, timestamp);
                }
            }
        }
コード例 #3
0
        protected void TryToConnect()
        {
            reqsOutstanding = 1;
            Agent newAgent = new Agent(this, 0, "BrokerAgent");

            Agents.Add(newAgent.AgentKey(), newAgent);
            client = new Client();
            client.Connect(url.Hostname, url.Port, null, url.AuthName, url.AuthPassword);
            clientSession = client.CreateSession(timeout);
            //clientSession.SetAutoSync(false) ;
            string name = System.Text.Encoding.UTF8.GetString(clientSession.GetName());

            replyName = "reply-" + name;
            topicName = "topic-" + name;
            clientSession.SetAutoSync(true);
            Option[] options = new Option[] { Option.EXCLUSIVE, Option.AUTO_DELETE };

            // This queue is used for responses to messages which are sent.
            clientSession.QueueDeclare(replyName, options);
            clientSession.ExchangeBind(replyName, "amq.direct", replyName);
            clientSession.AttachMessageListener(this, "rdest");
            clientSession.MessageSubscribe(replyName, "rdest", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED, null, 0, null);
            clientSession.MessageSetFlowMode("rdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("rdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("rdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);

            // This queue is used for unsolicited messages sent to this class.
            clientSession.QueueDeclare(topicName, options);
            clientSession.AttachMessageListener(this, "tdest");
            clientSession.MessageSubscribe(topicName, "tdest", MessageAcceptMode.NONE, MessageAcquireMode.PRE_ACQUIRED, null, 0, null);
            clientSession.MessageSetFlowMode("tdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("tdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("tdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);

            outSession = client.CreateSession(timeout);
            outSession.ExchangeBind(replyName, "amq.direct", replyName);

            connected = true;
            consoleSession.HandleBrokerConnect(this);


            IEncoder encoder = CreateEncoder();

            this.SetHeader(encoder, 'B', 0);
            this.Send(encoder);
        }
コード例 #4
0
ファイル: Broker.cs プロジェクト: drzo/opensim4opencog
		protected void TryToConnect() {
			reqsOutstanding = 1 ;		
			Agent newAgent = new Agent(this,0,"BrokerAgent") ;
			Agents.Add(newAgent.AgentKey(), newAgent) ;
			client = new Client() ;
			client.Connect(url.Hostname, url.Port, null, url.AuthName, url.AuthPassword) ;
			clientSession = client.CreateSession(timeout) ;		
			//clientSession.SetAutoSync(false) ;
			string name = System.Text.Encoding.UTF8.GetString(clientSession.GetName()) ;
			replyName = "reply-" + name ;
			topicName = "topic-" + name ;
			clientSession.SetAutoSync(true) ;
			Option[] options = new Option[] {Option.EXCLUSIVE, Option.AUTO_DELETE} ;
		
			// This queue is used for responses to messages which are sent.	
			clientSession.QueueDeclare(replyName,options) ;
			clientSession.ExchangeBind(replyName,"amq.direct",replyName) ;
			clientSession.AttachMessageListener(this, "rdest") ;			
			clientSession.MessageSubscribe(replyName,"rdest",MessageAcceptMode.NONE,MessageAcquireMode.PRE_ACQUIRED,null,0,null) ;			  			  						
            clientSession.MessageSetFlowMode("rdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("rdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("rdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);  			
		
			// This queue is used for unsolicited messages sent to this class.
			clientSession.QueueDeclare(topicName, options) ;
			clientSession.AttachMessageListener(this, "tdest") ;			
			clientSession.MessageSubscribe(topicName,"tdest",MessageAcceptMode.NONE,MessageAcquireMode.PRE_ACQUIRED,null,0,null) ;							  									
            clientSession.MessageSetFlowMode("tdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("tdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("tdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);  				
			
			outSession = client.CreateSession(timeout) ;	
			outSession.ExchangeBind(replyName,"amq.direct",replyName) ;
			
			connected = true ;
			consoleSession.HandleBrokerConnect(this) ;		
				
			
			IEncoder encoder = CreateEncoder() ;
			this.SetHeader(encoder, 'B', 0) ;
			this.Send(encoder) ;
		}
コード例 #5
0
 public string AgentKey()
 {
     return(Agent.AgentKey(AgentBank, BrokerBank));
 }