Пример #1
0
 /// <summary>
 /// Starts listening for new data.
 /// </summary>
 /// <param name="router">Routes information recieved.</param>
 /// <param name="disconnecter">Action tooken on disconnection.</param>
 public void Start(RouteDataCallback router, DisconnectCallback disconnecter)
 {
     this.receiveBuffer = new byte[Node.ReceiveBufferSize];
     this.dataReceived  = new AsyncCallback(OnDataRecieved);
     this.disconnect    = disconnecter;
     this.routeData     = router;
     StandBy();
 }
Пример #2
0
 /// <summary>
 /// 初始化类型 TaskProxy 实例。
 /// </summary>
 /// <param name="name">消息收发器名称。该名称必须与服务进程的消息收发器名称一致。</param>
 /// <param name="timeout">超时时间。如果小于或等于0,则具有无限超时值的等待服务进程响应。</param>
 /// <param name="serverName">要连接的远程计算机的名称。默认为本地计算机。</param>
 public TaskProxy(String name, String serverName = ".", Int32 timeout = 20000)
 {
     _transceiver             = new MessageClientTransceiver(name, serverName, timeout);
     _transceiver.Disconnect += (a, b) =>
     {
         Terminate();
         DisconnectCallback?.Invoke();
     };
 }
Пример #3
0
        private void ReadAll <T>(ReadBuffer buffer, AllReadCallback callback, T arg, DisconnectCallback disconnectCallback)
        {
            var data = new ReadData {
                buffer             = buffer,
                callback           = callback,
                arg                = arg,
                disconnectCallback = disconnectCallback
            };

            pipe_.BeginRead(buffer.data, 0, buffer.data.Length, OnChunk, data);
        }
Пример #4
0
 public void RegisterForDisconnect(DisconnectCallback callback, object state)
 {
     lock (this)
     {
         if (!run)
         {
             throw new ObjectDisposedException("MessageTransceiver already disposed or connection terminated");
         }
         disconnectCallback = callback;
         disconnectState    = state;
     }
 }
Пример #5
0
 public SocketWrap(
     ConnectCallback ccb,
     ListenCallback lcb,
     ReceiveCallback rcb,
     DisconnectCallback dcb,
     ErrorCallback ecb)
 {
     _ccb = ccb;
     _rcb = rcb;
     _ecb = ecb;
     _lcb = lcb;
     _dcb = dcb;
     _recvBuf = new byte[1024];
 }
 public void AttatchOnDisconnect(DisconnectCallback callback)
 => this.DisconnectionCallback += (callback ?? throw new ArgumentNullException(nameof(callback)));
Пример #7
0
 public static FluentConnectionWrapper OnDisconnect(this FluentConnectionWrapper m, DisconnectCallback callback)
 {
     m.AttatchOnDisconnect(callback); return(m);
 }
Пример #8
0
 public AttendanceThread(Socket s, EndPoint e, int num, DisconnectCallback dcb)
 {
     numclients = num;
     socko = s;
     socko.ReceiveTimeout = 10000;
     ep = e;
     concreteDCB = dcb;
 }
Пример #9
0
 /// <summary>
 /// Adds a new callback to be called when the disconnect request is submitted
 /// </summary>
 /// <param name="callback">Callback to perform</param>
 public void RegisterDisconnectTask(DisconnectCallback callback)
 {
     disconnectCallbacks.Add(callback);
 }
Пример #10
0
 private void doDisconnect(String msg)
 {
     if (this.rtbDisplay.InvokeRequired)
     {
         DisconnectCallback d = new DisconnectCallback(doDisconnect);
         this.Invoke(d, new object[] { msg + "\n" });
     }
     else
     {
         this.rtbDisplay.AppendText(msg + "\n", Color.Gray);
     }
 }
Пример #11
0
 public AttendanceThread(Socket s, EndPoint e, DisconnectCallback dcb)
 {
     socko = s;
     socko.ReceiveTimeout = 0;
     socko.SendTimeout = 0;
     ep = e;
     concreteDCB = dcb;
 }