Exemple #1
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, new ConnectionOptions(),BindingScheme.TCP);
            _client.Open();
            var requestMessage = new RequestMessage();
            var registerMessage = new RegisterMessage { Counter = _counterType };
            Trace.WriteLine(registerMessage.Counter.ToString());
            requestMessage.SetBody(registerMessage);
            _client.Subscribe(requestMessage);
            resetEvent.WaitOne();
            _client.Close();

        }
Exemple #2
0
 public void Post(Codex.IPC.DataTypes.RequestMessage request)
 {
     base.Channel.Post(request);
 }
Exemple #3
0
 public Task <Codex.IPC.DataTypes.ResponseMessage> CallAsync(Codex.IPC.DataTypes.RequestMessage request)
 {
     return(base.Channel.CallAsync(request));
 }
Exemple #4
0
 public void UnSubscribe(Codex.IPC.DataTypes.RequestMessage request)
 {
     base.Channel.UnSubscribe(request);
 }
Exemple #5
0
 public Codex.IPC.DataTypes.ResponseMessage Call(Codex.IPC.DataTypes.RequestMessage request)
 {
     return(base.Channel.Call(request));
 }
Exemple #6
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.TryAdd(request.Header.ProcessID.ToString(), callback);
    OnMessageRecieved(null, new MessageRecievedEventArgs(request));
 }
Exemple #7
0
 public void Send(Codex.IPC.DataTypes.RequestMessage request)
 {
     base.Channel.Send(request);
 }
Exemple #8
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);
    callback?.Reply(response);
 }
Exemple #9
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.
 /// </remarks>
 public void Post(RequestMessage request)
 {
    var arg = new MessageRecievedEventArgs(request);
    OnMessageRecieved(null, arg);
 }
Exemple #10
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;
 }
Exemple #11
0
 public MessageRecievedEventArgs(RequestMessage request)
 {
    Request = request;
    Response = new ResponseMessage(Request.Header);
 }
Exemple #12
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;
    IIPCDuplexCallback notUsed = null;
    if (_subscriptions.ContainsKey(request.Header.ProcessID.ToString()))
       _subscriptions.TryRemove(request.Header.ProcessID.ToString(), out notUsed);
    OnMessageRecieved(null, new MessageRecievedEventArgs(request));
 }