Advertisement
Guest User

Untitled

a guest
Jun 21st, 2011
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  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.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement