Ejemplo n.º 1
0
Archivo: Program.cs Proyecto: 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);
         }
     }
 }
Ejemplo n.º 2
0
Archivo: Program.cs Proyecto: 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[] { });
         }
     }
 }