Exemplo n.º 1
0
 public ServiceManager(ObjectBus objectBus)
 {
     if (objectBus == null)
         throw new ArgumentNullException ("objectBus");
     this.objectBus = objectBus;
     objectBus.RegisterType (typeof(ServiceAnnounceMessage), ServiceAnnouncementReceived);
     objectBus.RegisterType (typeof(ServiceResponseMessage), ServiceResponseReceived);
     objectBus.RegisterType (typeof(ServiceRequestMessage), ServiceRequestReceived);
     objectBus.RegisterType (typeof(ServiceDestroyMessage), ServiceDestroyReceived);
     objectBus.RegisterType (typeof(ServiceManagerReadyMessage), ServiceManagerReadyMessageReceived);
     objectBus.Start ();
 }
Exemplo n.º 2
0
Arquivo: Program.cs Projeto: vebin/BD2
 static void HandleConnection(string modeName, Guid chatServiceAnouncementType, System.Net.Sockets.TcpClient TC)
 {
     if (modeName == null)
         throw new ArgumentNullException ("modeName");
     if (TC == null)
         throw new ArgumentNullException ("TC");
     System.IO.Stream PS = TC.GetStream ();
     StreamHandler SH = new StreamHandler (PS);
     ObjectBus OB = new ObjectBus (SH);
     ServiceManager SM = new ServiceManager (OB);
     if (modeName == "Server") {
         SM.AnnounceService (new ServiceAnnounceMessage (Guid.NewGuid (), chatServiceAnouncementType, "Chat", null), StreamPairAgent.CreateAgent);
         SM.AnounceReady ();
     }
     if (modeName == "Client") {
         SM.WaitForRemoteReady ();
         foreach (ServiceAnnounceMessage RSA in SM.EnumerateRemoteServices ()) {
             Console.WriteLine ("Service found: {0}", RSA.Name);
             SM.RequestService (RSA, null, StreamPairAgent.CreateAgent, null);
         }
     }
 }
Exemplo n.º 3
0
Arquivo: Program.cs Projeto: vebin/BD2
 static void HandleConnection(string modeName, Guid fileShareServiceAnouncementType, System.Net.Sockets.TcpClient TC)
 {
     if (modeName == null)
         throw new ArgumentNullException ("modeName");
     if (TC == null)
         throw new ArgumentNullException ("TC");
     System.IO.Stream PS = TC.GetStream ();
     StreamHandler SH = new StreamHandler (PS);
     ObjectBus OB = new ObjectBus (SH);
     ServiceManager SM = new ServiceManager (OB);
     if (modeName == "Server") {
         SM.AnnounceService (new ServiceAnnounceMessage (Guid.NewGuid (), fileShareServiceAnouncementType, "FileShare", null), FileShareAgent.CreateAgent);
     }
     if (modeName == "Client") {
         foreach (ServiceAnnounceMessage RSA in SM.EnumerateRemoteServices ()) {
             Console.WriteLine ("Service found: {0}", RSA.Name);
             Console.WriteLine ("Press Enter to request service");
             ConsoleReadLine ();
             SM.RequestService (RSA, new byte[] { }, FileShareAgent.CreateAgent, new byte[] { });
         }
     }
 }