Ejemplo n.º 1
0
 protected void RemoteReceiveCallback(IAsyncResult ar)
 {
     try
     {
         int received = RemoteSocket.EndReceive(ar);
         if (received == 0)
         {
             Dispose();
             return;
         }
         var args = new ClientReceiveEventArgs(RemoteBuffer, received);
         OnFromClient(args);
         if (args.Cancel)
         {
             RemoteSocket.BeginReceive(
                 RemoteBuffer,
                 0,
                 RemoteBuffer.Length,
                 SocketFlags.None,
                 RemoteReceiveCallback,
                 null);
             return;
         }
         LocalSocket.BeginSend(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, LocalSendCallback, null);
     }
     catch
     {
         Dispose();
     }
 }
Ejemplo n.º 2
0
        protected virtual void OnFromServer(ClientReceiveEventArgs e)
        {
            EventHandler <ClientReceiveEventArgs> handler = ReceiveFromServer;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
 protected void RemoteReceiveCallback(IAsyncResult ar)
 {
     try
     {
         int received = RemoteSocket.EndReceive(ar);
         if(received == 0)
         {
             Dispose();
             return;
         }
         var args = new ClientReceiveEventArgs(RemoteBuffer, received);
         OnFromClient(args);
         if(args.Cancel)
         {
             RemoteSocket.BeginReceive(
                                       RemoteBuffer, 
                 0, 
                 RemoteBuffer.Length, 
                 SocketFlags.None, 
                 RemoteReceiveCallback, 
                 null);
             return;
         }
         LocalSocket.BeginSend(RemoteBuffer, 0, RemoteBuffer.Length, SocketFlags.None, LocalSendCallback, null);
     }
     catch
     {
         Dispose();
     }
 }
Ejemplo n.º 4
0
 protected virtual void OnFromServer(ClientReceiveEventArgs e)
 {
     EventHandler<ClientReceiveEventArgs> handler = ReceiveFromServer;
     if(handler != null)
     {
         handler(this, e);
     }
 }