warsocketcpslimit.cpp

来自「ftpserver very good sample」· C++ 代码 · 共 92 行

CPP
92
字号
#include "StdAfx.h"#define WAR_CPS_LIMIT_WANT_PLUGINS 1#include "WarSocketCpsLimit.h"   // class implemented/////////////////////////////// PUBLIC ///////////////////////////////////////WarSocketCpsLimit *WarSocketCpsLimit::spThis;//============================= LIFECYCLE ====================================WarSocketCpsLimit::WarSocketCpsLimit() :WarPluginModule("WarSocketCpsLimit"){    if (NULL != spThis)        WarThrow(WarError(WAR_ERR_ALREADY_INITIALIZED), NULL);    spThis = this;    // Register what classes we have interest in    NotifyOnClassInstance("WarSocketIo");}// WarSocketCpsLimitWarSocketCpsLimit::~WarSocketCpsLimit(){    if (this == spThis)        spThis = NULL;}// ~WarSocketCpsLimit//============================= OPERATORS  ====================================//============================= OPERATIONS ===================================void WarSocketCpsLimit::EnableCps(    WarSocket *pSocket,    const unsigned delayMs,    const unsigned holdMs,    const unsigned minCnt,    const unsigned maxCnt,    const unsigned minCps,    const unsigned maxCps,    const WarSocketCpsLimit::DirectionE forDirection){    switch(forDirection)    {    case RECEIVING:        pSocket->GetSocketIo().AddPlugin(            WarSocketIo::PLUGIN_ON_RECEIVED,            new WarSocketCpsLimit_WarSocketIo_OnReceived(pSocket,            delayMs,            holdMs,            minCnt,            maxCnt,            minCps,            maxCps));        break;    case SENDING:        pSocket->GetSocketIo().AddPlugin(            WarSocketIo::PLUGIN_ON_RECEIVED,            new WarSocketCpsLimit_WarSocketIo_OnSent(pSocket,            delayMs,            holdMs,            minCnt,            maxCnt,            minCps,            maxCps));        break;            }}//============================= CALLBACK   ===================================void WarSocketCpsLimit::OnClassInstance(    WarPluginBaseSupport *pClassInstance,    const NotificationE notificationType)    throw(WarException) // Should not throw{   ; // We are initialized manually, on demand.}//============================= ACCESS     ===================================//============================= INQUIRY    ===================================/////////////////////////////// PROTECTED  ////////////////////////////////////////////////////////////////// PRIVATE    ///////////////////////////////////

⌨️ 快捷键说明

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