tuesdayonly.cpp

来自「SconeServer is a modular, object-orienta」· C++ 代码 · 共 78 行

CPP
78
字号
/* SconeServer exampleA very simple module which only allows connections on Tuesdays!Copyright (c) 2000-2006 Andrew Wedgbury <wedge@sconemad.com> */#include "sconex/Module.h"#include "sconex/ModuleInterface.h"#include "sconex/Date.h"//=============================================================================// Our module class, which must be derived from scx::Moduleclass TuesdayOnlyModule : public scx::Module {public:  TuesdayOnlyModule();    virtual ~TuesdayOnlyModule();  virtual std::string info() const;    virtual int init();  virtual bool connect(    scx::Descriptor* endpoint,    scx::ArgList* args  );};// The following must be present to allow the resulting// shared object to be used as a SconeServer module.SCONESERVER_MODULE(TuesdayOnlyModule);//=============================================================================// ConstructorTuesdayOnlyModule::TuesdayOnlyModule()  : scx::Module("tuesdayonly", scx::VersionTag(1,0,0)){  // Specify module name and version in base constructor}//=============================================================================// DestructorTuesdayOnlyModule::~TuesdayOnlyModule(){  // Nothing to do here}//=============================================================================// Return an information string describing this modulestd::string TuesdayOnlyModule::info() const{  return "Copyright (c) 2000-2005 Andrew Wedgbury\n"  "A very simple example module which only allows connections on Tuesdays!\n";}  //=============================================================================// Initialise the moduleint TuesdayOnlyModule::init(){  // Everything is fine so return 0  return 0;}//=============================================================================// Notification of connection attemptbool TuesdayOnlyModule::connect(  scx::Descriptor* /* endpoint */,  scx::ArgList* /* args */){  // Return 'true' only if today is a tuesday, otherwise return 'false' -  // causing the connection to be dropped.  return (scx::Date::now().day() == scx::Date::Tue);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?