This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 21st, 2011  |  syntax: C#  |  size: 1.87 KB  |  views: 176  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public interface ClientInterface
  2.     {
  3.         [OperationContract]
  4.         void OnCallback(object aUpdatedObject);
  5.  
  6.     }
  7.  
  8. [ServiceContract(SessionMode=SessionMode.Required,
  9.         CallbackContract=typeof(ClientInterface))]
  10.     public interface RequestInterface
  11.     {
  12.  
  13.         [OperationContract]
  14.         void Subscribe();
  15.         /* */
  16.         [OperationContract]
  17.         TransmissionClass GetInterface();
  18.     }
  19.  
  20.  
  21. [KnownType(typeof(TransmissionClass))]
  22.     public class RequestHandler : RequestInterface
  23.     {
  24.         private static int MAXIMUM = 32760;
  25.         internal static RequestHandler Instance;
  26.         private List<ClientInterface> iClients = new List<ClientInterface>();
  27.         ClientInterface channel;
  28.  
  29.         public RequestHandler()
  30.         {
  31.             Instance = this;
  32.         }
  33.  
  34.         public TransmissionClass GetInterface()
  35.         {
  36.             Form1.AddText("method invoked by:" + Thread.CurrentContext.ToString());
  37.            
  38.             List<MySubInterface> tList = new List<MySubInterface>();
  39.            
  40.             for(int i = MAXIMUM; i >= 0; i--)
  41.             {
  42.                 tList.Add(new TransmissionSubclass(i));
  43.             }
  44.  
  45.             MAXIMUM += 1;
  46.             /* */
  47.             TransmissionClass tTC = new TransmissionClass("invokedMethod", tList);
  48.             Form1.AddText("created:" + tTC);
  49.             return tTC;
  50.         }
  51.  
  52.         public void Subscribe()
  53.         {
  54.             channel = OperationContext.Current.GetCallbackChannel<ClientInterface>();
  55.         }
  56.  
  57.         public void Send()
  58.         {
  59.             try
  60.             {
  61.                 channel.OnCallback("I love deadlines. I like the whooshing sound they make as they fly by.");
  62.             }
  63.             catch (Exception ex)
  64.             {
  65.                 Form1.AddText(ex.GetType() + "|" + ex.Message);
  66.             }
  67.         }
  68.     }
clone this paste RAW Paste Data