📄 warsocketcpslimit.cpp
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -