예제 #1
0
        public DefaultServiceHandler()
        {
            //
            // TODO: Add constructor logic here
            //
            m_async_receive = new AsyncReceive();
            m_async_send    = new AsyncSend();
            m_async_init    = new AsyncSend();

            m_event_queue = new EventQueue();
            m_async_work  = new AsyncWork();
        }
예제 #2
0
 public override void  handle_receive(AsyncReceive ar)
 {
     if (ar.bytes_received() > 0)
     {
         m_event_queue.putQ(ar.message());
         // start a new receive
         byte [] buffer = new byte[128];
         m_async_receive.receive(buffer);
     }
     else
     {
         Console.WriteLine("handle_receive(), Disconnected");
         while (m_event_queue.itemQsize() > 0)
         {
             Console.WriteLine("{0}", m_event_queue.itemQsize());
             System.Threading.Thread.Sleep(5000);
         }
         m_sock.Close();
         // A good implementation will initiate a shutdown of the socket here, whicl allowing time for the
         //sends to drain. This couls be done by looking at the work queue to see how many sends are
         // pending
         //m_sock.Close();
     }
 }
예제 #3
0
 public virtual void handle_receive(AsyncReceive ar)
 {
 }