本文整理汇总了C++中RemoteClient类的典型用法代码示例。如果您正苦于以下问题:C++ RemoteClient类的具体用法?C++ RemoteClient怎么用?C++ RemoteClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RemoteClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getClientIDs
void ClientInterface::UpdatePlayerList()
{
if (m_env) {
std::vector<u16> clients = getClientIDs();
m_clients_names.clear();
if(!clients.empty())
infostream<<"Players:"<<std::endl;
for (u16 i : clients) {
RemotePlayer *player = m_env->getPlayer(i);
if (player == NULL)
continue;
infostream << "* " << player->getName() << "\t";
{
MutexAutoLock clientslock(m_clients_mutex);
RemoteClient* client = lockedGetClientNoEx(i);
if (client)
client->PrintInfo(infostream);
}
m_clients_names.emplace_back(player->getName());
}
}
}
示例2: getClientIDs
void ClientInterface::UpdatePlayerList()
{
if (m_env != NULL)
{
std::vector<u16> clients = getClientIDs();
m_clients_names.clear();
if(!clients.empty())
infostream<<"Players:"<<std::endl;
for(std::vector<u16>::iterator
i = clients.begin();
i != clients.end(); ++i) {
Player *player = m_env->getPlayer(*i);
if (player == NULL)
continue;
infostream << "* " << player->getName() << "\t";
{
MutexAutoLock clientslock(m_clients_mutex);
RemoteClient* client = lockedGetClientNoEx(*i);
if(client != NULL)
client->PrintInfo(infostream);
}
m_clients_names.push_back(player->getName());
}
}
}
示例3: RequestEditQueue
bool Frontend::RequestEditQueue(DownloadQueue::EEditAction action, int offset, int id)
{
RemoteClient client;
client.SetVerbose(false);
IdList ids = { id };
return client.RequestServerEditQueue(action, offset, nullptr, &ids, nullptr, rmId);
}
示例4: onClientMessageReceived
void Server::onClientMessageReceived(QString message)
{
RemoteClient *client = qobject_cast<RemoteClient*>(sender());
sendMessage(client->nickName() + " : " + message);
emit messageReceived(client->nickName(), message);
}
示例5: getClient
void Server::handleCommand_DeletedBlocks(NetworkPacket* pkt) {
const auto peer_id = pkt->getPeerId();
auto & packet = *(pkt->packet);
std::vector<v3s16> deleted_blocks;
packet[TOSERVER_DELETEDBLOCKS_DATA].convert(deleted_blocks);
RemoteClient *client = getClient(peer_id);
for (auto &block : deleted_blocks)
client->SetBlockDeleted(block);
}
示例6: RemoteClient
void NetworkConnection::newConnection()
{
QTcpSocket* tcpSocket = m_tcpServer.nextPendingConnection();
if(tcpSocket->open(QIODevice::ReadWrite))
{
if(m_clientName.isEmpty())
m_clientName = "Unknown";
RemoteClient* rc = new RemoteClient();
rc->setClientName(m_clientName);
rc->setSocket(tcpSocket);
emit incommingConnection(rc);
}
}
示例7: RemoteClient
void Server::onClientConnected()
{
QTcpSocket *clientSocket = m_server->nextPendingConnection();
RemoteClient *client = new RemoteClient(clientSocket, this);
m_clients << client;
client->setNickname(clientSocket->peerAddress().toString());
for (RemoteClient *client : m_clients) {
client->sendMessage("client connect" + clientSocket->peerAddress().toString());
}
connect(client,SIGNAL(messageReceived(QString)),
this,SLOT(onClientMessageReceived(QString)));
}
示例8: ProcessClientRequest
void ProcessClientRequest()
{
RemoteClient* Client = new RemoteClient();
switch (g_pOptions->GetClientOperation())
{
case Options::opClientRequestListFiles:
Client->RequestServerList(true, false, g_pOptions->GetMatchMode() == Options::mmRegEx ? g_pOptions->GetEditQueueText() : NULL);
break;
case Options::opClientRequestListGroups:
Client->RequestServerList(false, true, g_pOptions->GetMatchMode() == Options::mmRegEx ? g_pOptions->GetEditQueueText() : NULL);
break;
case Options::opClientRequestListStatus:
Client->RequestServerList(false, false, NULL);
break;
case Options::opClientRequestDownloadPause:
Client->RequestServerPauseUnpause(true, eRemotePauseUnpauseActionDownload);
break;
case Options::opClientRequestDownloadUnpause:
Client->RequestServerPauseUnpause(false, eRemotePauseUnpauseActionDownload);
break;
case Options::opClientRequestSetRate:
Client->RequestServerSetDownloadRate(g_pOptions->GetSetRate());
break;
case Options::opClientRequestDumpDebug:
Client->RequestServerDumpDebug();
break;
case Options::opClientRequestEditQueue:
Client->RequestServerEditQueue((DownloadQueue::EEditAction)g_pOptions->GetEditQueueAction(),
g_pOptions->GetEditQueueOffset(), g_pOptions->GetEditQueueText(),
g_pOptions->GetEditQueueIDList(), g_pOptions->GetEditQueueIDCount(),
g_pOptions->GetEditQueueNameList(), (eRemoteMatchMode)g_pOptions->GetMatchMode());
break;
case Options::opClientRequestLog:
Client->RequestServerLog(g_pOptions->GetLogLines());
break;
case Options::opClientRequestShutdown:
Client->RequestServerShutdown();
break;
case Options::opClientRequestReload:
Client->RequestServerReload();
break;
case Options::opClientRequestDownload:
Client->RequestServerDownload(g_pOptions->GetAddNZBFilename(), g_pOptions->GetArgFilename(),
g_pOptions->GetAddCategory(), g_pOptions->GetAddTop(), g_pOptions->GetAddPaused(), g_pOptions->GetAddPriority(),
g_pOptions->GetAddDupeKey(), g_pOptions->GetAddDupeMode(), g_pOptions->GetAddDupeScore());
break;
case Options::opClientRequestVersion:
Client->RequestServerVersion();
break;
case Options::opClientRequestPostQueue:
Client->RequestPostQueue();
break;
case Options::opClientRequestWriteLog:
Client->RequestWriteLog(g_pOptions->GetWriteLogKind(), g_pOptions->GetLastArg());
break;
case Options::opClientRequestScanAsync:
Client->RequestScan(false);
break;
case Options::opClientRequestScanSync:
Client->RequestScan(true);
break;
case Options::opClientRequestPostPause:
Client->RequestServerPauseUnpause(true, eRemotePauseUnpauseActionPostProcess);
break;
case Options::opClientRequestPostUnpause:
Client->RequestServerPauseUnpause(false, eRemotePauseUnpauseActionPostProcess);
break;
case Options::opClientRequestScanPause:
Client->RequestServerPauseUnpause(true, eRemotePauseUnpauseActionScan);
break;
case Options::opClientRequestScanUnpause:
Client->RequestServerPauseUnpause(false, eRemotePauseUnpauseActionScan);
break;
case Options::opClientRequestHistory:
case Options::opClientRequestHistoryAll:
Client->RequestHistory(g_pOptions->GetClientOperation() == Options::opClientRequestHistoryAll);
break;
//.........这里部分代码省略.........
示例9: RequestSetDownloadRate
bool Frontend::RequestSetDownloadRate(int rate)
{
RemoteClient client;
client.SetVerbose(false);
return client.RequestServerSetDownloadRate(rate);
}
示例10: RequestPauseUnpause
bool Frontend::RequestPauseUnpause(bool pause)
{
RemoteClient client;
client.SetVerbose(false);
return client.RequestServerPauseUnpause(pause, rpDownload);
}
示例11: connection
bool Frontend::RequestFileList()
{
const char* controlIp = !strcmp(g_Options->GetControlIp(), "0.0.0.0") ? "127.0.0.1" : g_Options->GetControlIp();
Connection connection(controlIp, g_Options->GetControlPort(), false);
bool OK = connection.Connect();
if (!OK)
{
return false;
}
SNzbListRequest ListRequest;
InitMessageBase(&ListRequest.m_messageBase, rrList, sizeof(ListRequest));
ListRequest.m_fileList = htonl(m_fileList);
ListRequest.m_serverState = htonl(m_summary);
if (!connection.Send((char*)(&ListRequest), sizeof(ListRequest)))
{
return false;
}
// Now listen for the returned list
SNzbListResponse ListResponse;
bool read = connection.Recv((char*) &ListResponse, sizeof(ListResponse));
if (!read ||
(int)ntohl(ListResponse.m_messageBase.m_signature) != (int)NZBMESSAGE_SIGNATURE ||
ntohl(ListResponse.m_messageBase.m_structSize) != sizeof(ListResponse))
{
return false;
}
CharBuffer buf;
if (ntohl(ListResponse.m_trailingDataLength) > 0)
{
buf.Reserve(ntohl(ListResponse.m_trailingDataLength));
if (!connection.Recv(buf, buf.Size()))
{
return false;
}
}
connection.Disconnect();
if (m_summary)
{
m_pauseDownload = ntohl(ListResponse.m_downloadPaused);
m_remainingSize = Util::JoinInt64(ntohl(ListResponse.m_remainingSizeHi), ntohl(ListResponse.m_remainingSizeLo));
m_currentDownloadSpeed = ntohl(ListResponse.m_downloadRate);
m_downloadLimit = ntohl(ListResponse.m_downloadLimit);
m_threadCount = ntohl(ListResponse.m_threadCount);
m_postJobCount = ntohl(ListResponse.m_postJobCount);
m_upTimeSec = ntohl(ListResponse.m_upTimeSec);
m_dnTimeSec = ntohl(ListResponse.m_downloadTimeSec);
m_standBy = ntohl(ListResponse.m_downloadStandBy);
m_allBytes = Util::JoinInt64(ntohl(ListResponse.m_downloadedBytesHi), ntohl(ListResponse.m_downloadedBytesLo));
}
if (m_fileList && ntohl(ListResponse.m_trailingDataLength) > 0)
{
RemoteClient client;
client.SetVerbose(false);
client.BuildFileList(&ListResponse, buf, DownloadQueue::Guard());
}
return true;
}
示例12: ThreadStarted
//.........这里部分代码省略.........
TimeTaker t("mapgen::make_block()");
mapgen->makeChunk(&data);
if (enable_mapgen_debug_info == false)
t.stop(true); // Hide output
}
{
//envlock: usually 0ms, but can take either 30 or 400ms to acquire
JMutexAutoLock envlock(m_server->m_env_mutex);
ScopeProfiler sp(g_profiler, "EmergeThread: after "
"Mapgen::makeChunk (envlock)", SPT_AVG);
map->finishBlockMake(&data, modified_blocks);
block = map->getBlockNoCreateNoEx(p);
if (block) {
/*
Do some post-generate stuff
*/
v3s16 minp = data.blockpos_min * MAP_BLOCKSIZE;
v3s16 maxp = data.blockpos_max * MAP_BLOCKSIZE +
v3s16(1,1,1) * (MAP_BLOCKSIZE - 1);
// Ignore map edit events, they will not need to be sent
// to anybody because the block hasn't been sent to anybody
MapEditEventAreaIgnorer
ign(&m_server->m_ignore_map_edit_events_area,
VoxelArea(minp, maxp));
try { // takes about 90ms with -O1 on an e3-1230v2
m_server->getScriptIface()->environment_OnGenerated(
minp, maxp, emerge->getBlockSeed(minp));
} catch(LuaError &e) {
m_server->setAsyncFatalError(e.what());
}
EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
m_server->m_env->activateBlock(block, 0);
}
}
}
/*
Set sent status of modified blocks on clients
*/
// NOTE: Server's clients are also behind the connection mutex
//conlock: consistently takes 30-40ms to acquire
JMutexAutoLock lock(m_server->m_con_mutex);
// Add the originally fetched block to the modified list
if (block)
modified_blocks[p] = block;
// Update weather data in mapblock
/*for(std::map<v3s16, MapBlock *>::iterator
i = modified_blocks.begin();
i != modified_blocks.end(); ++i) {
map->updateBlockHeat(m_server->m_env, MAP_BLOCKSIZE*i->first, i->second);
}*/
// Set the modified blocks unsent for all the clients
for (std::map<u16, RemoteClient*>::iterator
i = m_server->m_clients.begin();
i != m_server->m_clients.end(); ++i) {
RemoteClient *client = i->second;
if (modified_blocks.size() > 0) {
// Remove block from sent history
client->SetBlocksNotSent(modified_blocks, 1);
}
}
if (mapgen->heat_cache.size() > 1000) {
mapgen->heat_cache.clear();
mapgen->humidity_cache.clear();
}
}
catch (VersionMismatchException &e) {
std::ostringstream err;
err << "World data version mismatch in MapBlock "<<PP(last_tried_pos)<<std::endl;
err << "----"<<std::endl;
err << "\""<<e.what()<<"\""<<std::endl;
err << "See debug.txt."<<std::endl;
err << "World probably saved by a newer version of Minetest."<<std::endl;
m_server->setAsyncFatalError(err.str());
}
catch (SerializationError &e) {
std::ostringstream err;
err << "Invalid data in MapBlock "<<PP(last_tried_pos)<<std::endl;
err << "----"<<std::endl;
err << "\""<<e.what()<<"\""<<std::endl;
err << "See debug.txt."<<std::endl;
err << "You can ignore this using [ignore_world_load_errors = true]."<<std::endl;
m_server->setAsyncFatalError(err.str());
}
END_DEBUG_EXCEPTION_HANDLER(errorstream)
log_deregister_thread();
return NULL;
}
示例13: DSTACK
void Server::ProcessData(NetworkPacket *pkt)
{
DSTACK(__FUNCTION_NAME);
// Environment is locked first.
//JMutexAutoLock envlock(m_env_mutex);
ScopeProfiler sp(g_profiler, "Server::ProcessData");
auto peer_id = pkt->getPeerId();
std::string addr_s;
try{
Address address = getPeerAddress(peer_id);
addr_s = address.serializeString();
// drop player if is ip is banned
if(m_banmanager->isIpBanned(addr_s)){
std::string ban_name = m_banmanager->getBanName(addr_s);
infostream<<"Server: A banned client tried to connect from "
<<addr_s<<"; banned name was "
<<ban_name<<std::endl;
// This actually doesn't seem to transfer to the client
DenyAccess(peer_id, std::string("Your ip is banned. Banned name was ") + ban_name);
return;
}
}
catch(con::PeerNotFoundException &e)
{
/*
* no peer for this packet found
* most common reason is peer timeout, e.g. peer didn't
* respond for some time, your server was overloaded or
* things like that.
*/
verbosestream<<"Server::ProcessData(): Canceling: peer "
<<peer_id<<" not found"<<std::endl;
return;
}
try
{
auto datasize = pkt->getSize();
if(datasize < 2)
return;
int command;
std::map<int, msgpack::object> packet;
msgpack::unpacked msg;
if (!con::parse_msgpack_packet(pkt->getString(0), datasize, &packet, &command, &msg)) {
verbosestream<<"Server: Ignoring broken packet from " <<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl;
return;
}
if(command == TOSERVER_INIT_LEGACY)
{
RemoteClient* client = getClient(peer_id, CS_Created);
// If net_proto_version is set, this client has already been handled
if(client->getState() > CS_Created)
{
verbosestream<<"Server: Ignoring multiple TOSERVER_INITs from "
<<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl;
return;
}
verbosestream<<"Server: Got TOSERVER_INIT from "<<addr_s<<" (peer_id="
<<peer_id<<")"<<std::endl;
// Do not allow multiple players in simple singleplayer mode.
// This isn't a perfect way to do it, but will suffice for now
if(m_simple_singleplayer_mode && m_clients.getClientIDs().size() > 1){
infostream<<"Server: Not allowing another client ("<<addr_s
<<") to connect in simple singleplayer mode"<<std::endl;
DenyAccess(peer_id, "Running in simple singleplayer mode.");
return;
}
// First byte after command is maximum supported
// serialization version
u8 client_max;
packet[TOSERVER_INIT_FMT].convert(&client_max);
u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
int deployed = std::min(client_max, our_max);
// If it's lower than the lowest supported, give up.
if(deployed < SER_FMT_CLIENT_VER_LOWEST)
deployed = SER_FMT_VER_INVALID;
if(deployed == SER_FMT_VER_INVALID)
{
actionstream<<"Server: A mismatched client tried to connect from "
<<addr_s<<std::endl;
infostream<<"Server: Cannot negotiate serialization version with "
<<addr_s<<std::endl;
DenyAccess(peer_id, std::string(
"Your client's version is not supported.\n"
"Server version is ")
+ (g_version_string) + "."
//.........这里部分代码省略.........
示例14: RequestPauseUnpause
bool Frontend::RequestPauseUnpause(bool bPause)
{
RemoteClient client;
client.SetVerbose(false);
return client.RequestServerPauseUnpause(bPause, eRemotePauseUnpauseActionDownload);
}
示例15: RequestEditQueue
bool Frontend::RequestEditQueue(DownloadQueue::EEditAction eAction, int iOffset, int iID)
{
RemoteClient client;
client.SetVerbose(false);
return client.RequestServerEditQueue(eAction, iOffset, NULL, &iID, 1, NULL, eRemoteMatchModeID);
}