예제 #1
0
 /// <summary>
 /// Send message from the client.
 /// </summary>
 /// <param name="request">Object representing the requested information</param>
 /// <remarks>
 /// This should be used either when you need a one way notification or an out of band reply.
 /// </remarks>
 public void Send(RequestMessage request)
 {
     IIPCDuplexCallback callback = OperationContext.Current.GetCallbackChannel<IIPCDuplexCallback>();
     var response = Call(request);
     if (callback != null)
         callback.Reply(response);
 }
예제 #2
0
 /// <summary>
 /// Subscribe message from the client.
 /// </summary>
 /// <param name="request">Object representing the requested information</param>
 /// <remarks>
 /// The client subscribes to the events from the server.
 /// This may include client specific events or general broadcasts.
 /// </remarks>
 public void Subscribe(RequestMessage request)
 {
     IIPCDuplexCallback callback = OperationContext.Current.GetCallbackChannel<IIPCDuplexCallback>();
     request.Header.MessageType = (int)MessageType.SUBSCRIBE;
     if (!_subscriptions.ContainsKey(request.Header.ProcessID.ToString()))
         _subscriptions.Add(request.Header.ProcessID.ToString(), callback);
     OnMessageRecieved(null, new MessageRecievedEventArgs(request));
 }
예제 #3
0
        static void ClientThreadLoop(object mrevent)
        {
            ManualResetEvent resetEvent = (ManualResetEvent)mrevent;
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
            _client = ClientHelper.GetDuplexClient(instanceContext,_serverProcId.ToString(), ClientHelper.ServerLocation.REMOTE,"localhost",64000);
            _client.Open();
            var requestMessage = new RequestMessage();
            var registerMessage = new RegisterMessage() { Counter = CounterType.MEMORY };
            Trace.WriteLine(registerMessage.Counter.ToString());
            requestMessage.SetBody<RegisterMessage>(registerMessage);
            _client.Subscribe(requestMessage);
            resetEvent.WaitOne();
            _client.Close();

        }
예제 #4
0
 /// <summary>
 /// UnSubscribe message from the client.
 /// </summary>
 /// <param name="request">Object representing the requested information</param>
 public void UnSubscribe(RequestMessage request)
 {
     request.Header.MessageType = (int)MessageType.UNSUBSCRIBE;
     if (_subscriptions.ContainsKey(request.Header.ProcessID.ToString()))
         _subscriptions.Remove(request.Header.ProcessID.ToString());
     OnMessageRecieved(null, new MessageRecievedEventArgs(request));
 }
예제 #5
0
 /// <summary>
 /// Call message from the client requesting information.
 /// </summary>
 /// <param name="request">Object representing the requested information</param>
 /// <returns>Response</returns>
 public ResponseMessage Call(RequestMessage request)
 {
     var arg = new MessageRecievedEventArgs(request);
     OnMessageRecieved(null, arg);
     return arg.Response;
 }
예제 #6
0
 public MessageRecievedEventArgs(RequestMessage request)
 {
     Request = request;
     Response = new ResponseMessage(Request.Header);
 }