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.

Set up formatter for unserializationBinaryMessageFormatter rea<strong>de</strong>r = newBinaryMessageFormatter();msqmMessage.Formatter = rea<strong>de</strong>r;// Get the Message and post it on thisMessage agentMsg = (Message) msqmMessage.Body;PostMessage(agentMsg);// Try to receive other messagesqueue.BeginReceive ();}}}/// /// Allows IAgents to unregister during their finalization./// /// /// public void Unregister(AgentId id){NameServer.GetNS().Unregister(id);Debug.Assert(id != null);lock (table){table.Remove(id);}}3. Class MAP.NameServerusing System;using System.Collections;using System.Diagnostics;using System.Runtime.Remoting;using System.Runtime.Remoting.Channels;using System.Runtime.Remoting.Channels.Http;namespace MAP{/// /// Name Server: maps AgentIds with AgentAddresses./// The singleton NS resi<strong><strong>de</strong>s</strong> on the main host only. Other hosts use aproxy and/// synchronized remote calls to the instance on the main host./// public class NameServer : MarshalByRefObject // For remote access{//****** STATIC PART ******// The unique instance.private static NameServer Instance;// Remoting parametersprivate static readonly string FUNCTION = "NS";/// /// Returns the singleton instance./// /// MSc EMOOSE Thesis – http://www.emn.fr/EMOOSE 72

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

Saved successfully!

Ooh no, something went wrong!