10.07.2015 Views

pdf - 395 K - Ecole des mines de Nantes

pdf - 395 K - Ecole des mines de Nantes

pdf - 395 K - Ecole des mines de Nantes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

string path = MakePath(".", Middleware.GetProcessId());if (! System.Messaging.MessageQueue.Exists(path))mQueue = System.Messaging.MessageQueue.Create(path);elsemQueue = new System.Messaging.MessageQueue(path);// Setups asynchronous receivingmQueue.ReceiveCompleted +=newReceiveCompletedEventHandler(RemoteMessageArrived);mQueue.BeginReceive ();}/// /// Allows for the retrieval of a local IAgent from its ID./// Returns null if not found./// /// /// private IAgent FindAgent(AgentId id){Debug.Assert(id != null);IAgent agent = null;lock (table){if (table.ContainsKey(id))agent = (IAgent) table[id];elseConsole.WriteLine("Cannot find agent with id{0} in process {1}",id, Middleware.ThisAddress);}return agent;}/// /// Returns the MessageQueue of a MessageTransporter on aremote computer./// /// /// private System.Messaging.MessageQueueGetMessageQueue(AgentAddress address){System.Messaging.MessageQueue queue = null;lock (queueTable){if (queueTable.ContainsKey(address))// Queue already knownqueue = (System.Messaging.MessageQueue)queueTable[address];else{// Get queue objectSystem.Messaging.MessageQueue[] queues =null;try{queues = System.Messaging.MessageQueue.GetPrivateQueuesByMachine(address.Computer);}MSc EMOOSE Thesis – http://www.emn.fr/EMOOSE 69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!