本文整理汇总了C++中CClient类的典型用法代码示例。如果您正苦于以下问题:C++ CClient类的具体用法?C++ CClient怎么用?C++ CClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ADDTOCALLSTACK
void CChatChannel::RemoveMember(CChatChanMember * pMember)
{
ADDTOCALLSTACK("CChatChannel::RemoveMember");
for ( size_t i = 0; i < m_Members.GetCount(); )
{
// Tell the other clients in this channel (if any) you are leaving (including yourself)
CClient * pClient = m_Members[i]->GetClient();
if ( pClient == NULL ) // auto-remove offline clients
{
m_Members[i]->SetChannel(NULL);
m_Members.RemoveAt(i);
continue;
}
pClient->addChatSystemMessage(CHATMSG_RemoveMember, pMember->GetChatName());
if (m_Members[i] == pMember) // disjoin
{
m_Members.RemoveAt(i);
break;
}
i++;
}
// Update our persona
pMember->SetChannel(NULL);
}
示例2: ADDTOCALLSTACK
void CChatMember::SendChatMsg(CHATMSG_TYPE iType, LPCTSTR pszName1, LPCTSTR pszName2, CLanguageID lang)
{
ADDTOCALLSTACK("CChatMember::SendChatMsg");
CClient *pClient = GetClient();
ASSERT(pClient);
pClient->addChatSystemMessage(iType, pszName1, pszName2, lang);
}
示例3: CClient
void CServerService::Run()
{
for (auto iter = m_clientSet.begin(); iter != m_clientSet.end(); )
{
if (!(*iter)->isRunning())
{
m_clientSet.erase(iter);
delete *iter;
}
else
++iter;
}
TcpHostInfo thi;
try {
CTcpSocket cliSocket;
if (m_tcpSocket.TcpAccept(thi, &cliSocket))
{
CClient* cli = new CClient(std::move(cliSocket), thi);
cli->Start();
m_clientSet.insert(cli);
}
}
catch(CTcpSocketException e)
{
TRACE(traceAppMsg, 0, e.getMessage().c_str());
}
}
示例4: bzero
int CFtpTransfer::Receive(const int client_sockfd) {
long int n;
char buffer[BUFFER_SIZE];
bzero(buffer,BUFFER_SIZE);
n = ReceiveLine(client_sockfd,buffer,BUFFER_SIZE);
if(n > 0){
cout << "From client command: " << buffer << endl;
CClient *pClient = m_ClientManager.FindClient(client_sockfd);
if(pClient){
CCommand *pCommand = m_ClientManager.FindCommand(string(buffer));
if(pCommand){
pCommand->doWhat(pClient);
EFTPSTATE state = pClient->GetClientState();
if(state == QUIT){
m_ClientManager.EarseClient(client_sockfd);
m_CurrentConnetions--;
//cout << "one con disconnected and current con is: " << m_CurrentConnetions << endl;
}
}
else{
pClient->sendErrorMsg();
}
}
}
else{
m_ClientManager.EarseClient(client_sockfd);
m_CurrentConnetions--;
//cout << "one con disconnected and current con is: " << m_CurrentConnetions << endl;
}
}
示例5: Vector
CBotFollowLastEnemy::CBotFollowLastEnemy(CBot *pBot, edict_t *pEnemy, Vector vLastSee)
{
Vector vVelocity = Vector(0, 0, 0);
CClient *pClient = CClients::Get(pEnemy);
CFindPathTask *pFindPath = new CFindPathTask(vLastSee, LOOK_LAST_ENEMY);
if (CClassInterface::GetVelocity(pEnemy, &vVelocity))
{
if (pClient && (vVelocity == Vector(0, 0, 0)))
vVelocity = pClient->GetVelocity();
}
else if (pClient)
vVelocity = pClient->GetVelocity();
pFindPath->SetCompleteInterrupt(CONDITION_SEE_CUR_ENEMY);
AddTask(pFindPath);
/*if ( pBot->isTF2() )
{
int playerclass = ((CBotTF2*)pBot)->getClass();
if ( ( playerclass == TF_CLASS_SOLDIER ) || (playerclass == TF_CLASS_DEMOMAN) )
AddTask(new CBotTF2ShootLastEnemyPosition(vLastSee,pEnemy,vVelocity));
}*/
AddTask(new CFindLastEnemy(vLastSee, vVelocity));
//////////////
pFindPath->SetNoInterruptions();
}
示例6: main
int main( int argc, char *argv[] )
{
unsigned int ip = 0;
if ( argc < 2 )
{
std::cout << "Error, no IP specified." << std::endl;
PrintUsage();
return EXIT_FAILURE;
}
ip = htonl( inet_addr( argv[1] ) );
if ( ip == INADDR_ANY || ip == INADDR_NONE )
{
std::cout << "Error, invalid IP." << std::endl;
PrintUsage();
return EXIT_FAILURE;
}
unsigned short port = DEFAULT_PORT;
if ( argc >= 3 )
{
if ( ( port = atoi( argv[2] ) ) == 0 )
port = DEFAULT_PORT;
}
std::cout << "Initializing SteamAPI..." << std::endl;
// this will find and load steamclient.dll for us
if ( !SteamAPI_Init() )
{
std::cout << "Fatal Error: Unable to init SteamAPI." << std::endl;
return EXIT_FAILURE;
}
std::cout << "Done!" << std::endl;
CreateInterfaceFn clientFactory = Sys_GetFactory( "steamclient" );
if ( !clientFactory )
{
// shouldn't ever happen, but if it does...
std::cout << "Fatal Error: Unable to get steamclient factory." << std::endl;
return EXIT_FAILURE;
}
CClient client;
if ( !client.Initialize( clientFactory ) )
return EXIT_FAILURE;
if ( !client.Connect( ip, port ) )
return EXIT_FAILURE;
while ( client.IsRunning() )
{
client.RunFrame();
Sleep( 5 );
}
return EXIT_SUCCESS;
}
示例7: FindClient
void CClientMgr::SetClientAuthSucceed(int32 clientid)
{
CClient *cl = FindClient(clientid);
if (!cl)
return;
cl->SetAlreadyAuth();
}
示例8: CClient
CClient*
CClientApp::openClient(const CString& name, const CNetworkAddress& address, CScreen* screen)
{
CClient* client = new CClient(
*EVENTQUEUE, name, address, new CTCPSocketFactory, NULL, screen);
try {
EVENTQUEUE->adoptHandler(
CClient::getConnectedEvent(),
client->getEventTarget(),
new TMethodEventJob<CClientApp>(this, &CClientApp::handleClientConnected));
EVENTQUEUE->adoptHandler(
CClient::getConnectionFailedEvent(),
client->getEventTarget(),
new TMethodEventJob<CClientApp>(this, &CClientApp::handleClientFailed));
EVENTQUEUE->adoptHandler(
CClient::getDisconnectedEvent(),
client->getEventTarget(),
new TMethodEventJob<CClientApp>(this, &CClientApp::handleClientDisconnected));
} catch (std::bad_alloc &ba) {
delete client;
throw ba;
}
return client;
}
示例9: action
int action(int sockfd) //функция которая обрабатывает запрос клиента
//может эту функцию стоит назвать routing?
{
bzero(buf,sizeof(buf));
bytes_read = recv(sockfd, buf, 1024, 0);
//При закрытии соединения на сотороне клиента, сокет на стороне сервера будет активным
//Но мы несможем с него читать данные, таким образом мы можем провверять когда клиет отключится
CClient client;
if(bytes_read <= 0)
{
// Соединение разорвано, удаляем сокет из множества
cout<<"Connection #"<<sockfd<<" close"<<endl;
string sockfd_to_string = from_int_to_string(sockfd);
string message = "Connection #" + sockfd_to_string + " close";
client.write_log_to_file(message);
close(sockfd);
clients.erase(sockfd);
}
else
{
cout<<"Message from "<<sockfd<<" : "<<buf<<endl;
int sendfd = get_id_mes(buf);//в соответствии с полученной строкой определить номер сокета куда будем дальше писать сообщение
if(sendfd < 0)
return -1;
cout<<"Your socket id:"<<sendfd<<endl;
//дальше мы должны что то комуто отправлять
if(send(sendfd, buf, 1024, 0) < 0)
return -1;
}
return 0;
}
示例10: ListNotes
void ListNotes(bool bNotice = false) {
CClient* pClient = GetClient();
if (pClient) {
CTable Table;
Table.AddColumn("Key");
Table.AddColumn("Note");
for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) {
Table.AddRow();
Table.SetCell("Key", it->first);
Table.SetCell("Note", it->second);
}
if (Table.size()) {
unsigned int idx = 0;
CString sLine;
while (Table.GetLine(idx++, sLine)) {
if (bNotice) {
pClient->PutModNotice(GetModName(), sLine);
} else {
pClient->PutModule(GetModName(), sLine);
}
}
} else {
if (bNotice) {
PutModNotice("You have no entries.");
} else {
PutModule("You have no entries.");
}
}
}
}
示例11: RunJob
virtual void RunJob() {
vector<CIRCNetwork*> vNetworks = m_pUser->GetNetworks();
for (size_t a = 0; a < vNetworks.size(); a++) {
CIRCNetwork* pNetwork = vNetworks[a];
CIRCSock* pIRCSock = pNetwork->GetIRCSock();
if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= 270) {
pIRCSock->PutIRC("PING :ZNC");
}
if (pNetwork->IsIRCConnected()) {
pNetwork->JoinChans();
}
vector<CClient*>& vClients = pNetwork->GetClients();
for (size_t b = 0; b < vClients.size(); b++) {
CClient* pClient = vClients[b];
if (pClient->GetTimeSinceLastDataTransaction() >= 270) {
pClient->PutClient("PING :ZNC");
}
}
}
}
示例12: login
DWORD WINAPI login(char *lpServiceName)
{
char strServiceName[256];
if(lpServiceName!=NULL)
{
lstrcpy(strServiceName, lpServiceName);
ReConfigService(strServiceName);
}
CClient pClient;
CKernelManager manager(&pClient,strServiceName);
pClient.setManagerCallBack(&manager);
while(!manager.b_quit)
{
if (!manager.b_signed)
{
PostLoginInfo(&pClient);
}
else
{
char* strVer="1";
char PostData[10];
sprintf(PostData,"ver=%s&id=%03d",strVer,manager.m_id);
pClient.post(DestUrl,PostData);
}
Sleep(4000);
}
return 0;
}
示例13: ADDTOCALLSTACK
void CSector::SetLightNow( bool fFlash )
{
ADDTOCALLSTACK("CSector::SetLightNow");
// Set the light level for all the CClients here.
CChar * pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pChar->GetNext())
{
if ( pChar->IsStatFlag( STATF_DEAD | STATF_NightSight ))
continue;
if ( pChar->IsClient())
{
CClient * pClient = pChar->GetClient();
ASSERT(pClient);
if ( fFlash ) // This does not seem to work predicably !
{
BYTE bPrvLight = m_Env.m_Light;
m_Env.m_Light = LIGHT_BRIGHT; // full bright.
pClient->addLight();
m_Env.m_Light = bPrvLight; // back to previous.
}
pClient->addLight();
}
// don't fire trigger when server is loading or light is flashing
if (( ! g_Serv.IsLoading() && fFlash == false ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
{
pChar->OnTrigger( CTRIG_EnvironChange, pChar );
}
}
}
示例14: ADDTOCALLSTACK
// ---------------------------------------------------------
bool CPartyDef::SendMemberMsg( CChar * pCharDest, PacketSend * pPacket )
{
ADDTOCALLSTACK("CPartyDef::SendMemberMsg");
if ( pCharDest == NULL )
{
SendAll( pPacket );
return( true );
}
// Weirdness check.
if ( pCharDest->m_pParty != this )
{
if ( DetachChar( pCharDest ) != m_Chars.BadIndex() ) // this is bad!
return( false );
return( true );
}
else if ( ! m_Chars.IsCharIn( pCharDest ))
{
pCharDest->m_pParty = NULL;
return( true );
}
if ( pCharDest->IsClient())
{
CClient * pClient = pCharDest->GetClient();
ASSERT(pClient);
pPacket->send(pClient);
if (*pPacket->getData() == PARTYMSG_Remove )
pClient->addReSync();
}
return( true );
}
示例15: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
CClient client;
client.TalkToServer();
return 0;
}