本文整理汇总了C++中Disconnect函数的典型用法代码示例。如果您正苦于以下问题:C++ Disconnect函数的具体用法?C++ Disconnect怎么用?C++ Disconnect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Disconnect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Disconnect
MyServer::~MyServer()
{
Disconnect();
}
示例2: Disconnect
void ConsoleSocket::OnRead()
{
uint32 readlen = (uint32)readBuffer.GetSize();
uint32 len;
char* p;
if ((readlen + m_pBufferPos) >= m_pBufferLen)
{
Disconnect();
return;
}
readBuffer.Read((uint8*)&m_pBuffer[m_pBufferPos], readlen);
m_pBufferPos += readlen;
// let's look for any newline bytes.
p = strchr(m_pBuffer, '\n');
while (p != NULL)
{
// windows is stupid. :P
len = (uint32)((p + 1) - m_pBuffer);
if (*(p - 1) == '\r')
*(p - 1) = '\0';
*p = '\0';
// handle the command
if (*m_pBuffer != '\0')
{
switch (m_state)
{
case STATE_USER:
m_username = string(m_pBuffer);
m_pConsole->Write("password: ");
m_state = STATE_PASSWORD;
break;
case STATE_PASSWORD:
m_password = string(m_pBuffer);
m_pConsole->Write("\r\nAttempting to authenticate. Please wait.\r\n");
m_state = STATE_WAITING;
m_requestNo = ConsoleAuthMgr::getSingleton().GenerateRequestId();
ConsoleAuthMgr::getSingleton().SetRequest(m_requestNo, this);
TestConsoleLogin(m_username, m_password, m_requestNo);
break;
case STATE_LOGGED:
if (!strnicmp(m_pBuffer, "quit", 4))
{
Disconnect();
break;
}
HandleConsoleInput(m_pConsole, m_pBuffer);
break;
}
}
// move the bytes back
if (len == m_pBufferPos)
{
m_pBuffer[0] = '\0';
m_pBufferPos = 0;
}
else
{
memcpy(m_pBuffer, &m_pBuffer[len], m_pBufferPos - len);
m_pBufferPos -= len;
}
p = strchr(m_pBuffer, '\n');
}
}
示例3: ClosePositioner
// ---------------------------------------------------------
// CT_LbsClientPosTp178::CloseTest
// Always called after the test, even if the test leaves
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp178::CloseTest()
{
ClosePositioner();
Disconnect();
}
示例4: sizeof
//-----------------------------------------------------------------------------
// Name: empty()
// Desc:
//-----------------------------------------------------------------------------
void CArmyWar::ReadPackets(void)
{
char data[1400];
struct sockaddr address;
clientData *clList;
int type;
int ind;
int local;
int ret;
char name[50];
DreamMessage mes;
mes.Init(data, sizeof(data));
while(ret = networkClient->GetPacket(mes.data, &address))
{
mes.SetSize(ret);
mes.BeginReading();
type = mes.ReadByte();
switch(type)
{
case DREAMSOCK_MES_ADDCLIENT:
local = mes.ReadByte();
ind = mes.ReadByte();
strcpy(name, mes.ReadString());
AddClient(local, ind, name);
break;
case DREAMSOCK_MES_REMOVECLIENT:
ind = mes.ReadByte();
LogString("Got removeclient %d message", ind);
RemoveClient(ind);
break;
case USER_MES_FRAME:
// Skip sequences
mes.ReadShort();
mes.ReadShort();
for(clList = clientList; clList != NULL; clList = clList->next)
{
// LogString("Reading DELTAFRAME for client %d", clList->index);
ReadDeltaMoveCommand(&mes, clList);
}
break;
case USER_MES_NONDELTAFRAME:
// Skip sequences
mes.ReadShort();
mes.ReadShort();
clList = clientList;
for(clList = clientList; clList != NULL; clList = clList->next)
{
LogString("Reading NONDELTAFRAME for client %d", clList->index);
ReadMoveCommand(&mes, clList);
}
break;
case USER_MES_SERVEREXIT:
MessageBox(NULL, "Server disconnected", "Info", MB_OK);
Disconnect();
break;
}
}
}
示例5: result
void CUser::SelectCharacter(Packet & pkt)
{
Packet result(WIZ_SEL_CHAR);
uint8 bResult, bInit;
if (isBanned())
{
Disconnect();
return;
}
pkt >> bResult >> bInit;
result << bResult;
if (bResult == 0 || !GetZoneID())
goto fail_return;
m_pMap = g_pMain->GetZoneByID(GetZoneID());
if (GetMap() == nullptr)
goto fail_return;
if (g_pMain->m_nServerNo != GetMap()->m_nServerNo)
{
_ZONE_SERVERINFO *pInfo = g_pMain->m_ServerArray.GetData(GetMap()->m_nServerNo);
if (pInfo == nullptr)
goto fail_return;
SendServerChange(pInfo->strServerIP, bInit);
return;
}
if (g_pMain->m_byBattleOpen == NO_BATTLE && GetFame() == COMMAND_CAPTAIN)
m_bFame = CHIEF;
// Disallow players from relogging in the opposite nation's home zone when an invasion's not running.
if (((GetZoneID() != GetNation() && GetZoneID() <= ZONE_ELMORAD && !g_pMain->m_byBattleOpen)
// also disallow players from logging back into war zones that aren't currently active...
|| (GetMap()->isWarZone() && (GetZoneID() - ZONE_BATTLE_BASE) != g_pMain->m_byBattleZone)
// Chaos, bdw and juraid montuain
|| isInTempleEventZone()
// Ronark Land, Ardream, RLB, Bifrost, Krowaz Dominion.
|| (g_pMain->m_byBattleOpen && (GetZoneID() == ZONE_RONARK_LAND
|| GetZoneID() == ZONE_ARDREAM
|| GetZoneID() == ZONE_RONARK_LAND_BASE
|| GetZoneID() == ZONE_BIFROST
|| GetZoneID() == ZONE_KROWAZ_DOMINION)) && !isGM()))
{
NativeZoneReturn();
Disconnect();
return;
}
SetLogInInfoToDB(bInit);
result << GetZoneID() << GetSPosX() << GetSPosZ() << GetSPosY() << g_pMain->m_byOldVictory;
m_bSelectedCharacter = true;
Send(&result);
SetUserAbility(false);
if (GetLevel() > MAX_LEVEL)
{
Disconnect();
return;
}
m_iMaxExp = g_pMain->GetExpByLevel(GetLevel());
SetRegion(GetNewRegionX(), GetNewRegionZ());
if (GetClanID() == -1)
{
SetClanID(0);
m_bFame = 0;
return;
}
else if (GetClanID() != 0
&& GetZoneID() > 2)
{
result.Initialize(WIZ_KNIGHTS_PROCESS);
result << uint8(KNIGHTS_LIST_REQ) << GetClanID();
g_pMain->AddDatabaseRequest(result, this);
}
return;
fail_return:
Send(&result);
}
示例6: _LIT
//.........这里部分代码省略.........
CRequestor* serviceId2 =
CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication,
KService2);
CRequestor* serviceId3 =
CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication,
KService3);
CRequestor* contactId1 =
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatTelephone,
KContact1);
CRequestor* contactId2 =
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatUrl,
KContact2);
CRequestor* contactId3 =
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatMail,
KContact3);
RRequestorStack stack = RRequestorStack();
CleanupStack::PushL(TCleanupItem(CleanOp ,&stack));
CleanupStack::PushL(serviceId1);
CleanupStack::PushL(serviceId2);
CleanupStack::PushL(serviceId3);
CleanupStack::PushL(contactId1);
CleanupStack::PushL(contactId2);
CleanupStack::PushL(contactId3);
ConnectL();
OpenPositioner();
stack.Append(serviceId1);
stack.Append(contactId1);
stack.Append(contactId2);
stack.Append(serviceId2);
stack.Append(contactId3);
stack.Append(serviceId3);
CleanupStack::Pop(contactId3);
CleanupStack::Pop(contactId2);
CleanupStack::Pop(contactId1);
CleanupStack::Pop(serviceId3);
CleanupStack::Pop(serviceId2);
CleanupStack::Pop(serviceId1);
TInt err = iPositioner.SetRequestor(stack);
if (err != KErrNone)
{
_LIT(KErrorAndLeave, "Problems setting requestorstack");
LogErrorAndLeaveL(KErrorAndLeave);
}
const TInt KPosBufFlatExpandSize = 100;
//ExternalizeL
CBufFlat* bufFlat = CBufFlat::NewL(KPosBufFlatExpandSize);
CleanupStack::PushL(bufFlat);
RBufWriteStream stream(*bufFlat);
CleanupClosePushL(stream);
stack.ExternalizeL(stream);
TPtr8 dataPtr((TUint8*)NULL, 0);
dataPtr.Set(bufFlat->Ptr(0));
CleanupStack::PopAndDestroy(&stream);
HBufC8* tempBuf = HBufC8::NewLC(bufFlat->Size());
TPtr8 ptr = tempBuf->Des();
ptr = dataPtr;
//Internalize
bufFlat->InsertL(0, ptr);
RBufReadStream rstream(*bufFlat);
CleanupClosePushL(rstream);
RRequestorStack stack2 = RRequestorStack();
CleanupStack::PushL(TCleanupItem(CleanOp ,&stack2));
stack2.InternalizeL(rstream);
// Verify the requestor stack
VerifyRequestorStackL(stack2);
_LIT(KResult, "The RequestorStack is correct after Externalize/Internalize");
INFO_PRINTF1(KResult);
CleanupStack::PopAndDestroy(1); // CleanupOp stack2
CleanupStack::PopAndDestroy(&rstream);
CleanupStack::PopAndDestroy(tempBuf);
CleanupStack::PopAndDestroy(bufFlat);
CleanupStack::PopAndDestroy(1); // CleanupOp stack1
ClosePositioner();
Disconnect();
}
示例7: Disconnect
///////////////////////////////////////////////////////////////////////////////
// Destruktor
MySQL::~MySQL(void)
{
Disconnect();
}
示例8: Disconnect
wxNumericTextCtrl::~wxNumericTextCtrl() {
Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxNumericTextCtrl::onTextChanged ), NULL, this );
}
示例9: CLOG_ENTERFN
// ---------------------------------------------------------
// CDownloadMgrSession::DispatchMessageL
// ---------------------------------------------------------
//
void CDownloadMgrSession::DispatchMessageL( const RMessage2& aMessage )
{
CLOG_ENTERFN( "CDownloadMgrSession::DispatchMessageL" )
CLOG_WRITE_FORMAT( "Message function: %d", aMessage.Function() )
// Set this false in case of the asyncron requests!!!
iComplete = ETrue;
SetCurrentMessage( aMessage );
// Fixed for Bug id - JJUN-78WCJ3 (DownloadMgrServer crashes under IPC attack)
//This check will make sure that before start of any download, InitializeL() should
// be called so that all the member variables will be initialized.
if(aMessage.Function() != EHttpDownloadMgrInitialize && iClientAppInstance == NULL)
{
User::Leave(KErrGeneral);
}
// check for session-relative requests
switch( aMessage.Function() )
{
case EHttpDownloadMgrInitialize:
{
InitializeL();
return;
}
case EHttpDownloadMgrCreateDownload:
{
NewDownloadL();
return;
}
case EHttpDownloadMgrAttach:
{
DownloadMgrAttachL();
return;
}
case EHttpDownloadAttach:
{
DownloadAttachL();
return;
}
case EHttpDownloadAttachToDownload:
{
AttachToDownloadL();
return;
}
case EHttpDownloadMgrPauseAll:
{
PauseAllL();
return;
}
case EHttpDownloadMgrStartAllL:
{
StartAllL();
return;
}
case EHttpDownloadMgrResetAll:
{
ResetAll();
return;
}
case EHttpDownloadMgrDeleteAll:
{
DeleteAll();
return;
}
case EHttpDownloadMgrDisconnect:
{
Disconnect();
return;
}
case EHttpDownloadMgrGetIntAttribute:
{
GetIntAttributeL();
return;
}
case EHttpDownloadMgrGetBoolAttribute:
{
GetBoolAttributeL();
return;
}
case EHttpDownloadMgrGetStringAttribute:
{
GetStringAttributeL();
return;
}
case EHttpDownloadMgrGetString8Attribute:
{
GetString8AttributeL();
return;
}
case EHttpDownloadMgrSetIntAttribute:
{
SetIntAttributeL();
return;
}
case EHttpDownloadMgrSetBoolAttribute:
{
//.........这里部分代码省略.........
示例10: Disconnect
CDatagrams::~CDatagrams()
{
Disconnect();
}
示例11: ParseRosterList
//.........这里部分代码省略.........
else if (!strcasecmp(entity->Attribute("id"), "save_conferences"))
{
_storage_supported = false;
sprintf(buffer, "Storage XEP-0049 is not supported on server. Cannot save conferences.\n\nNext time will try save to roster.");
ModalAlertFactory::Alert(buffer, "Pity", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
return;
}
else if (!strcasecmp(entity->Attribute("id"), "request_room_info"))
{
if (entity->Child("error") &&
entity->Child("error")->Child("text") &&
entity->Child("error")->Attribute("code"))
sprintf(buffer, "Error %s:\n\n%s", entity->Child("error")->Attribute("code"),
entity->Child("error")->Child("text")->Data());
else
sprintf(buffer, "Error %s", entity->Child("error")->Attribute("code"));
ModalAlertFactory::Alert(buffer, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
return;
}
if (entity->Child("error") &&
entity->Child("error")->Child("text") &&
entity->Child("error")->Attribute("code"))
sprintf(buffer, "Error %s:\n\n%s", entity->Child("error")->Attribute("code"),
entity->Child("error")->Child("text")->Data());
else
sprintf(buffer, "Error %s", entity->Child("error")->Attribute("code"));
ModalAlertFactory::Alert(buffer, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
Disconnect();
return;
}
if (entity->Attribute("id") && entity->Child("query") && entity->Child("query")->Attribute("xmlns") &&
entity->Attribute("type") &&
!strcasecmp(entity->Attribute("id"), "storage_request") &&
!strcasecmp(entity->Attribute("type"), "result") &&
!strcasecmp(entity->Child("query")->Attribute("xmlns"), "jabber:iq:private"))
{
if (entity->Child("query")->Child("storage"))
ParseStorage(entity->Child("query")->Child("storage"));
return;
}
if (entity->Attribute("type") && !strcasecmp(entity->Attribute("type"), "get"))
{
BString iq_from;
BString iq_id;
if (entity->Attribute("from")) {
iq_from = BString(entity->Attribute("from"));
}
if (entity->Attribute("id")) {
iq_id = BString(entity->Attribute("id"));
}
// handle version request
XMLEntity *query = entity->Child("query");
示例12: Send
bool NetPlayClient::Connect()
{
// send connect message
sf::Packet spac;
spac << NETPLAY_VERSION;
spac << netplay_dolphin_ver;
spac << m_player_name;
Send(spac);
enet_host_flush(m_client);
sf::Packet rpac;
// TODO: make this not hang
ENetEvent netEvent;
if (enet_host_service(m_client, &netEvent, 5000) > 0 && netEvent.type == ENET_EVENT_TYPE_RECEIVE)
{
rpac.append(netEvent.packet->data, netEvent.packet->dataLength);
}
else
{
return false;
}
MessageId error;
rpac >> error;
// got error message
if (error)
{
switch (error)
{
case CON_ERR_SERVER_FULL:
PanicAlertT("The server is full!");
break;
case CON_ERR_VERSION_MISMATCH:
PanicAlertT("The server and client's NetPlay versions are incompatible!");
break;
case CON_ERR_GAME_RUNNING:
PanicAlertT("The server responded: the game is currently running!");
break;
default:
PanicAlertT("The server sent an unknown error message!");
break;
}
Disconnect();
return false;
}
else
{
rpac >> m_pid;
Player player;
player.name = m_player_name;
player.pid = m_pid;
player.revision = netplay_dolphin_ver;
// add self to player list
m_players[m_pid] = player;
m_local_player = &m_players[m_pid];
m_dialog->Update();
is_connected = true;
return true;
}
}
示例13: Disconnect
void AutocloseMessageBox::EndModal( int retCode )
{
Disconnect( delay_timerID, wxEVT_TIMER, wxTimerEventHandler( AutocloseMessageBox::OnUnlock) );
m_delay_timer.Stop();
TimedMessageBox::EndModal( retCode );
}
示例14: AcMainThread
//.........这里部分代码省略.........
PackAddInt64(p, "CurrentAzureTimestamp", st.CurrentAzureTimestamp);
PackAddStr(p, "CurrentAzureSignature", st.CurrentAzureSignature);
Lock(ac->Lock);
{
if (StrCmpi(st.CurrentHostName, ac->DDnsStatus.CurrentHostName) != 0)
{
hostname_changed = true;
}
}
Unlock(ac->Lock);
if (hostname_changed == false)
{
if (SendPackWithHash(s, p))
{
// Receive result
if (RecvAll(s, &c, 1, false))
{
if (c && ac->Halt == false)
{
connect_was_ok = true;
established_tick = Tick64();
AcWaitForRequest(ac, s, ¶m);
}
}
}
}
FreePack(p);
}
else
{
WHERE;
}
Debug("VPN Azure: Disconnected.\n");
Lock(ac->Lock);
{
ac->IsConnected = false;
ac->CurrentSock = NULL;
ClearStr(ac->ConnectingAzureIp, sizeof(ac->ConnectingAzureIp));
}
Unlock(ac->Lock);
if (established_tick != 0)
{
if ((established_tick + (UINT64)AZURE_CONNECT_MAX_RETRY_INTERVAL) <= Tick64())
{
// If the connected time exceeds the AZURE_CONNECT_MAX_RETRY_INTERVAL, reset the retry counter.
last_reconnect_tick = 0;
num_reconnect_retry = 0;
next_reconnect_interval = AZURE_CONNECT_INITIAL_RETRY_INTERVAL;
}
}
Disconnect(s);
ReleaseSock(s);
}
else
{
Debug("VPN Azure: Error: Connect Failed.\n");
}
Free(host);
}
}
}
}
else
{
last_reconnect_tick = 0;
num_reconnect_retry = 0;
next_reconnect_interval = AZURE_CONNECT_INITIAL_RETRY_INTERVAL;
}
if (ac->Halt)
{
break;
}
if (connect_was_ok)
{
// If connection goes out after connected, increment connection success count to urge DDNS client query
next_ddns_retry_tick = Tick64() + MIN((UINT64)DDNS_VPN_AZURE_CONNECT_ERROR_DDNS_RETRY_TIME_DIFF * (UINT64)(num_reconnect_retry + 1), (UINT64)DDNS_VPN_AZURE_CONNECT_ERROR_DDNS_RETRY_TIME_DIFF_MAX);
}
if ((next_ddns_retry_tick != 0) && (Tick64() >= next_ddns_retry_tick))
{
next_ddns_retry_tick = 0;
ac->DDnsTriggerInt++;
}
Wait(ac->Event, rand() % 1000);
}
}
示例15: ElListenerProc
// Listener thread
void ElListenerProc(THREAD *thread, void *param)
{
TCP_ACCEPTED_PARAM *data = (TCP_ACCEPTED_PARAM *)param;
EL *e;
SOCK *s;
UCHAR rand[SHA1_SIZE];
UCHAR pass1[SHA1_SIZE], pass2[SHA1_SIZE];
// Validate arguments
if (data == NULL || thread == NULL)
{
return;
}
e = (EL *)data->r->ThreadParam;
s = data->s;
AddRef(s->ref);
SetTimeout(s, 5000);
LockList(e->AdminThreadList);
{
AddRef(thread->ref);
AddRef(s->ref);
Insert(e->AdminThreadList, thread);
Insert(e->AdminSockList, s);
}
UnlockList(e->AdminThreadList);
NoticeThreadInit(thread);
// Submit a challenge
Rand(rand, sizeof(rand));
SendAll(s, rand, sizeof(rand), false);
// Receive a response
SecurePassword(pass1, e->HashedPassword, rand);
Zero(pass2, sizeof(pass2));
RecvAll(s, pass2, sizeof(pass2), false);
if (Cmp(pass1, pass2, SHA1_SIZE) != 0)
{
// Password incorrect
bool code = false;
code = Endian32(code);
SendAll(s, &code, sizeof(code), false);
}
else
{
// Password match
bool code = true;
RPC *r;
code = Endian32(code);
SendAll(s, &code, sizeof(code), false);
SetTimeout(s, INFINITE);
// Start operation as a RPC server
r = StartRpcServer(s, ElRpcServer, e);
RpcServer(r);
RpcFree(r);
}
Disconnect(s);
ReleaseSock(s);
LockList(e->AdminThreadList);
{
if (Delete(e->AdminThreadList, thread))
{
ReleaseThread(thread);
}
if (Delete(e->AdminSockList, s))
{
ReleaseSock(s);
}
}
UnlockList(e->AdminThreadList);
}