home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / source / theatrix / netsrvr.cpp < prev    next >
C/C++ Source or Header  |  1995-05-04  |  861b  |  47 lines

  1. #include <iostream.h>
  2. #include "handler.h"
  3. #include "serial.h"
  4. #include "netfold.h"
  5. #include "netsrvr.h"
  6.  
  7.  
  8. void NetpackServer::startup()
  9.   {
  10.   CommParameters cp={ port,0,1,8,2400 };
  11.   if (netpacks_active)
  12.     {
  13.     commport=new CommPort(cp);
  14.     while (commport->input_char_ready())
  15.       commport->readcomm();
  16.     cout << "NETSRVR: using port " << port << "...\n";
  17.     }
  18.   }
  19.  
  20. void NetpackServer::check(Folder& fld)
  21.   {
  22.   if (commport)
  23.     {
  24.     if (commport->input_char_ready())
  25.       {
  26.       int p=commport->readcomm();
  27.       if (p >= 0 && p < MAXNETPACK)
  28.         fld.dispatch(p);
  29.       }
  30.     }
  31.   }
  32.  
  33. void NetpackServer::send(int p)
  34.   {
  35.   if (commport)
  36.     commport->writecomm(p);
  37.   }
  38.  
  39. void NetpackServer::shutdown()
  40.   {
  41.   if (commport)
  42.     {
  43.     delete commport;
  44.     cout << "NETSRVR: broke connection...\n";
  45.     }
  46.   }
  47.