Пример #1
0
        /// <summary>
        /// Connects with a spesified timeout value
        /// 0 = infinity
        /// </summary>
        /// <param name="Pipename"></param>
        /// <param name="Timeout"></param>
        public void Connect(string Pipename, int Timeout)
        {
            clientPipe = new ClientPipe(".", Pipename, p => p.StartMessageReaderAsync());

            clientPipe.DataReceived += (sndr, args) =>
            {
                ClientPipe sender = sndr as ClientPipe;
                OnMessageReceived(sender, args.Data);
            };

            clientPipe.Disconnect += (sndr, args) =>
                                     ClientDisconnected?.Invoke(this, new EventArgs());

            clientPipe.Connect(Timeout);
        }
Пример #2
0
 /// <summary>
 /// Proxy uses a callbackfunction that builds with the Response-class received from the server
 /// </summary>
 public Client()
 {
     clientPipe = null;
     proxy      = ProxyHelper.GetInstance <T>(OnMethodCallback);
 }
Пример #3
0
 /// <summary>
 /// Since the Pipes used is full duplex, the received messages are through other threads
 /// The OnMethodCallback needs this info, it waits for the responseEvent to be set
 /// </summary>
 /// <param name="clientPipe"></param>
 /// <param name="bytes"></param>
 private void OnMessageReceived(ClientPipe clientPipe, byte[] bytes)
 {
     responseJson = Encoding.ASCII.GetString(bytes);
     responseEvent.Set();
 }