本文整理汇总了C++中createClient函数的典型用法代码示例。如果您正苦于以下问题:C++ createClient函数的具体用法?C++ createClient怎么用?C++ createClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateSession
extern void CreateSession(const std::string& token, SessionCallback callback) {
std::string url = generateSignedUrl(GET_SESSION, { { "token", token } });
auto client = createClient();
client->Url(url)
.Mode(LastFmClient::Thread::Background)
.Run([token, callback](LastFmClient* client, int statusCode, CURLcode curlCode) {
Session session;
session.token = token;
if (statusCode == 200) {
try {
auto json = nlohmann::json::parse(client->Stream().str());
auto subscriber = json["session"];
session.username = subscriber.value("name", "");
session.sessionId = subscriber.value("key", "");
}
catch (...) {
/* not much we can do... */
}
}
validate(session);
callback(session);
});
}
示例2: gettimeofday
// 录制线程
void *thread_recording(void*)
{
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
env = BasicUsageEnvironment::createNew(*scheduler);
gettimeofday(&startTime, NULL);
streamURL = rtspPath;
// Create (or arrange to create) our client object:
if (createHandlerServerForREGISTERCommand) {
handlerServerForREGISTERCommand
= HandlerServerForREGISTERCommand::createNew(*env, continueAfterClientCreation0, handlerServerForREGISTERCommandPortNum, authDBForREGISTER, verbosityLevel, progName);
if (handlerServerForREGISTERCommand == NULL) {
*env << "Failed to create a server for handling incoming \"REGISTER\" commands: " << env->getResultMsg() << "\n";
} else {
*env << "Awaiting an incoming \"REGISTER\" command on port " << handlerServerForREGISTERCommand->serverPortNum() << "\n";
}
} else {
ourClient = createClient(*env, streamURL, verbosityLevel, progName);
if (ourClient == NULL) {
*env << "Failed to create " << clientProtocolName << " client: " << env->getResultMsg() << "\n";
shutdown();
}
ALOG(TX_LOG_INFO, TAG,"client create success\n");
continueAfterClientCreation1();
}
env->taskScheduler().doEventLoop();
}
示例3: acceptCommonHandler
static void acceptCommonHandler(int fd, int flags) {
client *c;
if ((c = createClient(fd)) == NULL) {
Log(WARNING,
"Error registering fd event for the new client: %s (fd=%d)",
strerror(errno),fd);
close(fd); /* May be already closed, just ignore errors */
return;
}
/* If maxclient directive is set and this is one client more... close the
* connection. Note that we create the client instead to check before
* for this condition, since now the socket is already set in non-blocking
* mode and we can send an error for free using the Kernel I/O */
if (listLength(server.clients) > server.maxclients) {
char *err = "-ERR max number of clients reached\r\n";
/* That's a best effort error message, don't check write errors */
if (write(c->fd,err,strlen(err)) == -1) {
/* Nothing to do, Just to avoid the warning... */
}
server.stat_rejected_conn++;
freeClient(c);
return;
}
server.stat_numconnections++;
c->flags |= flags;
}
示例4: debugf
err_t TcpServer::onAccept(tcp_pcb *clientTcp, err_t err)
{
// Anti DDoS :-)
if (system_get_free_heap_size() < 6500)
{
debugf("\r\n\r\nCONNECTION DROPPED\r\n\t(%d)\r\n\r\n", system_get_free_heap_size());
return ERR_MEM;
}
#ifdef NETWORK_DEBUG
debugf("onAccept state: %d K=%d", err, totalConnections);
list_mem();
#endif
if (err != ERR_OK)
{
//closeTcpConnection(clientTcp, NULL);
return err;
}
TcpConnection* client = createClient(clientTcp);
if (client == NULL) return ERR_MEM;
client->setTimeOut(timeOut);
onClient((TcpClient*)client);
return ERR_OK;
}
示例5: QObject
SimpleMenu::SimpleMenu(QWidget* parent, WelcomeScreen* screen)
: QObject(parent)
, m_screen(screen)
, m_protocol(0)
, m_state(READY)
, m_player1(0)
, m_player2(0)
{
if (m_screen) {
// create buttons
m_server_btn = m_screen->addButton(0, 0, QIcon(QLatin1String(iconServer)),
tr("Host Game"));
m_client_btn = m_screen->addButton(0, 1, QIcon(QLatin1String(iconClient)),
tr("Connect to Game"));
// create connections
connect(m_server_btn, SIGNAL(clicked()),
this, SLOT(createServer()));
connect(m_client_btn, SIGNAL(clicked()),
this, SLOT(createClient()));
// WiFi direct
wpa = new Wpa;
wpa->setEnabled(true);
QVariantMap args;
args["DeviceName"] = QHostInfo::localHostName();
const char dev_type[8] = {0x00, 0x09, 0x00, 0x50, 0xf2, 0x04, 0x00, 0x05};
args["PrimaryDeviceType"] = QByteArray(dev_type, 8);
wpa->setProperties(args);
}
}
示例6: main
/**
* Main program
* @return
*/
int main(int argc, char** argv) {
// document root
char* docroot = open_documentroot(argc, argv);
int server = creer_serveur(WEBSERVER_PORT);
printf("Server launched:\n");
// Mimes
loadMimes();
// Load stats
init_stats();
// Signaux
initialiser_signaux();
/**
* Get client request
* @return
*/
createClient(server, docroot);
return 0;
}
示例7: ESP_LOGD
/**
* @brief Set the value of a characteristic of a service on a remote device.
* @param [in] bdAddress
* @param [in] serviceUUID
* @param [in] characteristicUUID
*/
/* STATIC */ void BLEDevice::setValue(BLEAddress bdAddress, BLEUUID serviceUUID, BLEUUID characteristicUUID, std::string value) {
ESP_LOGD(LOG_TAG, ">> setValue: bdAddress: %s, serviceUUID: %s, characteristicUUID: %s", bdAddress.toString().c_str(), serviceUUID.toString().c_str(), characteristicUUID.toString().c_str());
BLEClient *pClient = createClient();
pClient->connect(bdAddress);
pClient->setValue(serviceUUID, characteristicUUID, value);
pClient->disconnect();
} // setValue
示例8: main
int main(int argc, char** argv)
{
if (usage(argc, argv) == false)
return -1;
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
env = BasicUsageEnvironment::createNew(*scheduler);
progName = argv[0];
verbosityLevel = 1;
playContinuously = True;
sendOptionsRequest = True;
notifyOnPacketArrival = True;
streamURL = argv[1];
gettimeofday(&startTime, NULL);
ourClient = createClient(*env, streamURL, verbosityLevel, progName);
if (ourClient == NULL)
{
*env << "Failed to create " << clientProtocolName << " client: " << env->getResultMsg() << "\n";
shutdown();
}
if (sendOptionsRequest)
getOptions(continueAfterOPTIONS);
else
continueAfterOPTIONS(NULL, 0, NULL);
env->taskScheduler().doEventLoop();
return 0;
}
示例9: LOG
void Worker::onConnection(int fd, int ev, void *data)
{
//check maxclients
Config *pConfig = Config::getInstance();
if(pMaster->pGlobals->clients >= pConfig->nMaxClients){
LOG("Connection is full");
close(fd);
return ;
}
//ip and port
struct sockaddr_in *pAddr = (struct sockaddr_in*)data;
char ip[17];
int port = ntohs(pAddr->sin_port);
memset(ip, 0, sizeof(ip));
inet_ntop(AF_INET, &pAddr->sin_addr, ip, 16);
//create client
createClient(fd, ip, port);
//free accept lock
if(pMaster->bUseAcceptMutex &&
UnLockAcceptMutex(&pMaster->pGlobals->lock, nPid))
{
//LOG("unlock accept mutex");
bHeldAcceptLock = false;
pServer->stop();
}
}
示例10: openClient
bool openClient (const double newSampleRate, const BitArray& newChannels)
{
sampleRate = newSampleRate;
channels = newChannels;
channels.setRange (actualNumChannels, channels.getHighestBit() + 1 - actualNumChannels, false);
numChannels = channels.getHighestBit() + 1;
if (numChannels == 0)
return true;
client = createClient();
if (client != 0
&& (tryInitialisingWithFormat (true, 4) || tryInitialisingWithFormat (false, 4)
|| tryInitialisingWithFormat (false, 3) || tryInitialisingWithFormat (false, 2)))
{
channelMaps.clear();
for (int i = 0; i <= channels.getHighestBit(); ++i)
if (channels[i])
channelMaps.add (i);
REFERENCE_TIME latency;
if (OK (client->GetStreamLatency (&latency)))
latencySamples = wasapi_refTimeToSamples (latency, sampleRate);
(void) OK (client->GetBufferSize (&actualBufferSize));
return OK (client->SetEventHandle (clientEvent));
}
return false;
}
示例11: main
/*
* Start of the ssl client
* There is a main thread and a receive thread
* Main:
*
* Recv:
*/
main() {
int status;
pthread_t recvThread;
pthread_t fsmThread;
sslStruct *sslC;
// For now this is just a function where we set all variables
// Ultimately this should be read from a resource file
initCfg();
// Connect to Unit under Test (UT)
initConnectionToServer();
// Ctrl-Z to give stats
initSignals();
status = pthread_create(&recvThread, NULL, &recvFunction, (void*)NULL);
if (status != 0) {
perror("Start Thread Error:"); return -1;
}
status = pthread_create(&fsmThread, NULL, &fsmFunction, (void*)NULL);
if (status != 0) {
perror("Start Thread Error:"); return -1;
}
fflush(stdout);
// For now just create 1 Client to test Server
sslC = createClient();
if (sslC == NULL)
return -1;
sendHello(sslC);
while(1);
}
示例12: acceptHandler
void acceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
int cport, cfd;
char cip[128];
redisClient *c;
REDIS_NOTUSED(el);
REDIS_NOTUSED(mask);
REDIS_NOTUSED(privdata);
cfd = anetAccept(server.neterr, fd, cip, &cport);
if (cfd == AE_ERR) {
redisLog(REDIS_VERBOSE,"Accepting client connection: %s", server.neterr);
return;
}
redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport);
if ((c = createClient(cfd)) == NULL) {
redisLog(REDIS_WARNING,"Error allocating resoures for the client");
close(cfd); /* May be already closed, just ingore errors */
return;
}
/* If maxclient directive is set and this is one client more... close the
* connection. Note that we create the client instead to check before
* for this condition, since now the socket is already set in nonblocking
* mode and we can send an error for free using the Kernel I/O */
if (server.maxclients && listLength(server.clients) > server.maxclients) {
char *err = "-ERR max number of clients reached\r\n";
/* That's a best effort error message, don't check write errors */
if (write(c->fd,err,strlen(err)) == -1) {
/* Nothing to do, Just to avoid the warning... */
}
freeClient(c);
return;
}
server.stat_numconnections++;
}
示例13: newFakeClient
/* ====================================================================
* Bring up / Teardown
* ==================================================================== */
void *load() {
g.c = newFakeClient();
g.c_noreturn = createClient(-1);
g.err_parse = createObject(
REDIS_STRING,
sdsnew("-ERR JSON Parse Error. You can debug with JSONDOCVALIDATE."));
return NULL;
}
示例14: DXDB_initServer
void DXDB_initServer() { //printf("DXDB_initServer\n");
server.alc.RestClient = createClient(-1);
server.alc.RestClient->flags |= REDIS_LUA_CLIENT;
aeCreateTimeEvent(server.el, 1, luaCronTimeProc, NULL, NULL);
initX_DB_Range(); initAccessCommands(); init_six_bit_strings();
init_DXDB_PersistentStorageItems(INIT_MAX_NUM_TABLES, INIT_MAX_NUM_INDICES);
initServer_Extra();
}
示例15: localIp
UtlBoolean SipProtocolServerBase::send(SipMessage* message,
const char* hostAddress,
int hostPort)
{
UtlBoolean sendOk = FALSE;
UtlString localIp(message->getLocalIp());
if (localIp.length() < 1)
{
localIp = mDefaultIp;
}
SipClient* client = createClient(hostAddress, hostPort, localIp);
if(client)
{
int isBusy = client->isInUseForWrite();
UtlString clientNames;
client->getClientNames(clientNames);
OsSysLog::add(FAC_SIP, PRI_DEBUG, "Sip%sServerBase::send %p isInUseForWrite %d, client info\n %s",
mProtocolString.data(), client, isBusy, clientNames.data());
sendOk = client->sendTo(*message, hostAddress, hostPort);
if(!sendOk)
{
OsTask* pCallingTask = OsTask::getCurrentTask();
OsTaskId_t callingTaskId = -1;
OsTaskId_t clientTaskId = -1;
if ( pCallingTask )
{
pCallingTask->id(callingTaskId);
}
client->id(clientTaskId);
if (clientTaskId != callingTaskId)
{
// Do not need to clientLock.acquireWrite();
// as deleteClient uses the locking list lock
// which is all that is needed as the client is
// already marked as busy when we called
// createClient above.
deleteClient(client);
client = NULL;
}
}
}
if(client)
{
releaseClient(client);
}
return(sendOk);
}