本文整理汇总了C++中CSession类的典型用法代码示例。如果您正苦于以下问题:C++ CSession类的具体用法?C++ CSession怎么用?C++ CSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: workThreadEventCB
void CWorkThreadEvent::workThreadEventCB(struct bufferevent *bev, short event, void *arg)
{
CSessionManager *pSessionManager = (CSessionManager *)arg;
CSession *pSession = pSessionManager->getSession(bev);
if (NULL == pSession)
{
bufferevent_free(bev);
return;
}
pSessionManager->setCurSession(pSession);
pSessionManager->getInterface()->onSocketClose();
pSessionManager->setCurSession(NULL);
if (pSession->getServerLinker())
{
CServerLinker *pServerLinker = (CServerLinker *)pSession->getHandle();
if (NULL != pServerLinker)
{
pSessionManager->delServerLinker(pServerLinker->getLinkerName());
pServerLinker->setLinked(false);
}
}
pSessionManager->dellSession(bev);
bufferevent_free(bev);
}
示例2: SessionTimeOutHandler
int CMain::SessionTimeOutHandler()
{
int nRet = 0;
time_t curTm = 0;
CSession *cSession = NULL;
curTm = time(NULL);
while(m_lstSession.size()){
cSession = m_lstSession.front();
if((curTm - cSession->GetSendTime()) <= m_nTimeOut){
return CLA_OK;
}
CLA_LOG(CLA_ERR,false,"Session timeout(curTm=%lu, sendTime=%lu, diff=%lu sessionId=%d, timeOut=%d)\n",
curTm, cSession->GetSendTime(), (curTm - cSession->GetSendTime()), cSession->GetSessionId(), m_nTimeOut);
nRet = UpdateHistErr(cSession, CLA_RSLT_CODE_TIME_OUT);
if(nRet != CLA_OK){
CLA_LOG(CLA_ERR,false,"Command history update failed(nRet=%d)\n",nRet);
}
delete cSession;
m_lstSession.pop_front();
}
return CLA_OK;
}
示例3: addServerLinker
void CWorkThreadEvent::addServerLinker(struct event_base *pMainBase,
CSessionManager *pSessionManager, OrderMsg &stOrderMsg)
{
struct bufferevent *pBev = NULL;
CSession *pSession = NULL;
CServerLinker *pServerLinker = (CServerLinker *)stOrderMsg.pHandle;
if (NULL == pServerLinker)
{
Q_Printf("%s", Q_EXCEPTION_NULLPOINTER);
return;
}
if (Q_INVALID_SOCK == pServerLinker->getSock())
{
Q_Printf("%s", "invalid socket");
return;
}
(void)evutil_make_socket_nonblocking(pServerLinker->getSock());
pBev = bufferevent_socket_new(pMainBase, pServerLinker->getSock(),
BEV_OPT_CLOSE_ON_FREE);
if (NULL == pBev)
{
Q_Printf("%s", "bufferevent_socket_new error.");
return;
}
if (Q_RTN_OK != pSessionManager->addSession(pBev))
{
bufferevent_free(pBev);
Q_Printf("%s", "add session error.");
return;
}
bufferevent_setcb(pBev, workThreadReadCB, NULL, workThreadEventCB,
pSessionManager);
if (Q_RTN_OK != bufferevent_enable(pBev, EV_READ | EV_WRITE))
{
pSessionManager->dellSession(pBev);
bufferevent_free(pBev);
pBev = NULL;
Q_Printf("%s", "bufferevent_enable error.");
return;
}
pSessionManager->addServerLinker(pServerLinker->getLinkerName(), pBev);
pSession = pSessionManager->getSession(pBev);
pSession->setHandle(pServerLinker);
pSession->setServerLinker(true);
pServerLinker->setLinked(true);
pSessionManager->getInterface()->onLinkedServer(pSession);
}
示例4: CreateSession
//##ModelId=41DDF2410119
CSession* CSessionFactory::CreateSession(DWORD dwLifeTime, SESSION_TYPE st )
{
// TODO: Add your specialized code here.
// NOTE: Requires a correct return value to compile.
CSession* pSession = NULL;
switch( st )
{
case ST_WS_SESSION:
{
pSession = new CWorldServerSession( dwLifeTime );
}
break;
//case ST_TEAM:
// {
// pSession = new CTeam( dwMinPlugs, dwMaxPlugs, dwLifeTime );
// }
//break;
}
if( pSession )
{
CGUID guid;
CGUID::CreateGUID(guid);
pSession->SetSessionType( st );
pSession->SetExID( guid );
s_mSessions[pSession->GetExID()] = pSession;
}
return pSession;
}
示例5: ClientThread
unsigned long __stdcall ClientThread(void* pVoid)
{
CSession *session = (CSession*)pVoid;
log(LOG_DEBUG, "DEBUG - client thread started for session S%d - ClientThread()\r\n", session->m_SessionIndex);
// Send Welcome Message
send(session->getMainSock(), MSG_CONNECTED_1, lstrlen(MSG_CONNECTED_1), 0);
send(session->getMainSock(), VERSION, lstrlen(VERSION), 0);
send(session->getMainSock(), MSG_CONNECTED_2, lstrlen(MSG_CONNECTED_2), 0);
// Dialog with FTP client
session->dialog();
// Object is deleted by Ftpd object
// wait for session to be closed
while (!session->m_IsClosed) {
Sleep(200);
}
// unregister session
(session->getCFtpd())->removeSession(session->m_SessionIndex);
return 0;
}
示例6: CoInitialize
void LimitMappingScripwise::getSymbolData()
{
HRESULT hr;
CoInitialize(NULL);
CDataSource connection;
CSession session;
CCommand<CAccessor<CTrade_Table> > artists1;
connection.OpenFromInitializationString(L"Provider=SQLNCLI11.1;[email protected];Persist Security Info=False;User ID=sa;Initial Catalog=TradeDataBase;Data Source=68.168.101.187;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=WINDOWS-LOJSHQK;Initial File Name=\"\";Use Encryption for Data=False;Tag with column collation when possible=False;MARS Connection=False;DataTypeCompatibility=0;Trust Server Certificate=False;Application Intent=READWRITE");
session.Open(connection);
_bstr_t strCommand="";
CString sel_login=GridTradeAndOrder::m_selected_login;
sel_login=sel_login.Mid(0,6);
_bstr_t strcode=sel_login;
//select distinct symbol,0 as 'Limit','' as 'Client_group','' as 'Client_Group1','' as 'Client_Group2','' as 'v','' as 'ba','' as 'TYPE','' as 'volume' ,'' AS 'cHECKtRADE' from mt5_deals where [Action] in (0,1) and symbol not in (select Symbol from Limit_Mapping where [login]='" + GridTradeAndOrder::m_selected_login + "' )union select Symbol,Limit from Limit_Mapping where [login]='" + GridTradeAndOrder::m_selected_login + "' "
strCommand="select distinct symbol,0 as 'LimitBuy',0 as 'Client_group','' as 'Client_Group1','' as 'Client_Group2','' as 'v','' as 'ba','' as 'TYPE','' as 'volume' ,'' AS 'cHECKtRADE' from mt5_deals where [Action] in (0,1) and symbol not in (select Symbol from Limit_Mapping where [login]='" + GridTradeAndOrder::m_selected_login + "' )union select Symbol,Limit,LimitSell as 'Client_group','' as 'Client_Group1','' as 'Client_Group2','' as 'v','' as 'ba','' as 'TYPE','' as 'volume' ,'' AS 'cHECKtRADE' from Limit_Mapping where [login]='" + GridTradeAndOrder::m_selected_login + "' ";
char* strCommand_char=(char*)strCommand;
hr=artists1.Open(session,strCommand_char);
int rows_count=0;
if(SUCCEEDED(hr))
{
while (artists1.MoveNext() == S_OK)
{
e_grid.QuickSetText(0,rows_count,artists1.m_Symbol );
e_grid.QuickSetText(1,rows_count,artists1.m_Order);
e_grid.QuickSetText(2,rows_count,artists1. m_Time);
rows_count=rows_count+1;
}
}
artists1.Close();
session.Close();
connection.Close();
}
示例7: OnAccept
//! acceptµ½client
bool CServerNetworkImp::OnAccept(ITcpSocket * s)
{
CSession * p = new CSession;
s->Initialize(m_ios, p);
p->InitSocketForServer(this, s,++m_nCurMaxConnectID);
g_nTotalLinked ++;
return true;
}
示例8: Show_NPBPStype1
UINT Show_NPBPStype1(void *pParam)
{
CNPBPSType1Grid* pThis= (CNPBPSType1Grid*)pParam;
CoInitialize(NULL);
CDataSource connection;
CSession session;
CCommand<CAccessor<NPBPSType1Table> > artists1;
HRESULT hr;
hr=connection.OpenFromInitializationString(L"Provider=SQLNCLI11.1;[email protected];Persist Security Info=False;User ID=sa;Initial Catalog=Tradedatabase;Data Source=68.168.101.187;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=WINDOWS-LOJSHQK;Initial File Name=\"\";Use Encryption for Data=False;Tag with column collation when possible=False;MARS Connection=False;DataTypeCompatibility=0;Trust Server Certificate=False;Application Intent=READWRITE");
if(SUCCEEDED(hr))
{
hr=session.Open(connection);
while (true )
{
CString strCommand=L"";
strCommand.Format(L"proc_Type2");
_bstr_t bstrCommand="";
bstrCommand=strCommand;
char* strCommand_char=(char*)bstrCommand;
if(SUCCEEDED(hr))
{
hr=artists1.Open(session,strCommand_char);
}
CNPBPSType1Grid::dealing_mutex.Lock();
if(SUCCEEDED(hr))
{
CNPBPSType1Grid::m_st_Dealing_Array.Clear();
CNPBPSType1Grid::st_Dealing m_st_Dealing={};
while (artists1.MoveNext() == S_OK)
{
CMTStr::Copy(m_st_Dealing.Section ,artists1.m_Section );
CMTStr::Copy(m_st_Dealing.Login ,artists1.m_login );
m_st_Dealing.Order =artists1.m_Order;
CMTStr::Copy(m_st_Dealing.Order_In_Time,artists1.m_Order_In_Time ) ;
m_st_Dealing.Deal=artists1.m_Deal ;
CMTStr::Copy(m_st_Dealing.Symbol ,artists1.m_Symbol );
CMTStr::Copy(m_st_Dealing.Type1 ,artists1.m_Type1 );
m_st_Dealing.Volume =artists1.m_Volume ;
m_st_Dealing.Price =artists1.m_Price;
CMTStr::Copy(m_st_Dealing.Comment,artists1.m_Comment);
CMTStr::Copy(m_st_Dealing.Status,artists1.m_Status);
CMTStr::Copy(m_st_Dealing.Type,artists1.m_Type);
CMTStr::Copy(m_st_Dealing.SubType,artists1.m_SubType);
CNPBPSType1Grid::m_st_Dealing_Array.Add(&m_st_Dealing);
}
artists1.Close();
}
CNPBPSType1Grid::dealing_mutex.Unlock();
Sleep(1000);
}
}
return 0;
}
示例9: main
int main(int argc, char **argv) {
CEventManager::instance();
CSDLManager::instance();
CClock::instance();
CSession *session = new CSession();
session->run();
return 0;
}
示例10: AssertMsgReturn
/* static */
bool UIMachine::startMachine(const QString &strID)
{
/* Some restrictions: */
AssertMsgReturn(vboxGlobal().isValid(), ("VBoxGlobal is invalid.."), false);
AssertMsgReturn(!vboxGlobal().virtualMachine(), ("Machine already started.."), false);
/* Restore current snapshot if requested: */
if (vboxGlobal().shouldRestoreCurrentSnapshot())
{
/* Create temporary session: */
CSession session = vboxGlobal().openSession(strID, KLockType_VM);
if (session.isNull())
return false;
/* Which VM we operate on? */
CMachine machine = session.GetMachine();
/* Which snapshot we are restoring? */
CSnapshot snapshot = machine.GetCurrentSnapshot();
/* Prepare restore-snapshot progress: */
CProgress progress = machine.RestoreSnapshot(snapshot);
if (!machine.isOk())
return msgCenter().cannotRestoreSnapshot(machine, snapshot.GetName(), machine.GetName());
/* Show the snapshot-discarding progress: */
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
if (progress.GetResultCode() != 0)
return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());
/* Unlock session finally: */
session.UnlockMachine();
/* Clear snapshot-restoring request: */
vboxGlobal().setShouldRestoreCurrentSnapshot(false);
}
/* For separate process we should launch VM before UI: */
if (vboxGlobal().isSeparateProcess())
{
/* Get corresponding machine: */
CMachine machine = vboxGlobal().virtualBox().FindMachine(vboxGlobal().managedVMUuid());
AssertMsgReturn(!machine.isNull(), ("VBoxGlobal::managedVMUuid() should have filter that case before!\n"), false);
/* Try to launch corresponding machine: */
if (!vboxGlobal().launchMachine(machine, VBoxGlobal::LaunchMode_Separate))
return false;
}
/* Try to create machine UI: */
return create();
}
示例11: PasvThread
unsigned long __stdcall PasvThread(void* pVoid)
{
CSession *session = (CSession*)pVoid;
sockaddr_in remoteAddr_in;
int nLen;
session->m_PasvThreadRunning = true;
log(LOG_DEBUG, "DEBUG - passive thread was started, waiting for incoming connection - PasvThread()\r\n");
nLen = sizeof(sockaddr_in);
// Accept incoming connections on passive port
SOCKET s = accept(session->getPasvSock(), (sockaddr *)&remoteAddr_in, &nLen);
if (s != INVALID_SOCKET) {
log(LOG_DEBUG, "DEBUG - passive thread received a connection (socket %d) - PasvThread()\r\n", s);
if (session->getPasvSock2()!=0) {
session->closePasvSock2();
}
session->setPasvSock2(s);
// session->m_PasvPort = -1;
// log(LOG_DEBUG, "Passive port free.\r\n");
}
session->closePasvSock();
session->getCFtpd()->freePasvPort(session->getPasvPort());
log(LOG_DEBUG, "DEBUG - passive thread was stopped - PasvThread()\r\n");
session->m_PasvThreadRunning = false;
return 0;
}
示例12: AssertReturn
void VBoxSnapshotsWgt::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false*/)
{
/* Get currently chosen item: */
SnapshotWgtItem *pItem = mTreeWidget->currentItem() ? static_cast<SnapshotWgtItem*>(mTreeWidget->currentItem()) : 0;
AssertReturn(pItem, (void)0);
/* Detemine snapshot id: */
QString strSnapshotId = pItem->snapshotId();
AssertReturn(!strSnapshotId.isNull(), (void)0);
/* Get currently desired snapshot: */
CSnapshot snapshot = mMachine.FindSnapshot(strSnapshotId);
/* Ask the user if he really wants to restore the snapshot: */
int iResultCode = AlertButton_Ok;
if (!fSuppressNonCriticalWarnings || mMachine.GetCurrentStateModified())
{
iResultCode = msgCenter().confirmSnapshotRestoring(snapshot.GetName(), mMachine.GetCurrentStateModified());
if (iResultCode & AlertButton_Cancel)
return;
}
/* If user also confirmed new snapshot creation: */
if (iResultCode & AlertOption_CheckBox)
{
/* Take snapshot of changed current state: */
mTreeWidget->setCurrentItem(curStateItem());
if (!takeSnapshot())
return;
}
/* Open a direct session (this call will handle all errors): */
CSession session = vboxGlobal().openSession(mMachineId);
if (session.isNull())
return;
/* Restore chosen snapshot: */
CConsole console = session.GetConsole();
CProgress progress = console.RestoreSnapshot(snapshot);
if (console.isOk())
{
msgCenter().showModalProgressDialog(progress, mMachine.GetName(), ":/progress_snapshot_restore_90px.png");
if (progress.GetResultCode() != 0)
msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), mMachine.GetName());
}
else
msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), mMachine.GetName());
/* Unlock machine finally: */
session.UnlockMachine();
}
示例13: AssertReturn
void VBoxSnapshotDetailsDlg::putBackToSnapshot()
{
AssertReturn (!mSnapshot.isNull(), (void) 0);
/* We need a session when we manipulate the snapshot data of a machine. */
CSession session = vboxGlobal().openExistingSession(mSnapshot.GetMachine().GetId());
if (session.isNull())
return;
mSnapshot.SetName(mLeName->text());
mSnapshot.SetDescription(mTeDescription->toPlainText());
/* Close the session again. */
session.UnlockMachine();
}
示例14: HandleTimeout
int HandleTimeout( void )
{
CSession* lpoSession = NULL;
if (GetCycle()->GetSessionManager()->Find(lpoSession, "127.0.0.1", 4001))
{
CAny loRequest(&moBlock);
lpoSession->Write(loRequest);
printf("HAHA Test.\n");
}
else
{
printf("HAHA Test failure.\n");
}
GetCycle()->GetTimer()->Add(this, 100 * 1000);
return 0;
}
示例15:
/**
@brief From CertifyServer
인증서버로 부터 받는다.
ReqLogin -> ReqUserLogin -> AckUserLogin
*/
bool CBasicC2SHandler_LoginSvr::AckUserLogin(certify::AckUserLogin_Packet &packet)
{
CSession *pClient = network::CheckClientId( &GetServer(), packet.id, 0, &m_BasicProtocol, packet.pdispatcher );
RETV(!pClient, false);
if (packet.errorCode != error::ERR_SUCCESS)
{
clog::Error( clog::ERROR_PROBLEM, "AckUserId Error!! client generate user id Error id=%s", packet.id.c_str());
m_BasicProtocol.AckLogIn(pClient->GetNetId(), SEND_T, packet.errorCode, packet.id, 0);
return false;
}
pClient->SetState(SESSIONSTATE_LOGIN); // login state
pClient->SetCertifyKey( packet.c_key );
m_BasicProtocol.AckLogIn(pClient->GetNetId(), SEND_T, packet.errorCode, packet.id, packet.c_key );
return true;
}