本文整理汇总了C++中sendToServer函数的典型用法代码示例。如果您正苦于以下问题:C++ sendToServer函数的具体用法?C++ sendToServer怎么用?C++ sendToServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendToServer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendToServer
void ClientInfo::selectItem( const QString& item )
{
// item in listBox selected, use LIST or GET depending of the node type.
if ( item.endsWith( "/" ) ) {
sendToServer( List, infoPath->text() + item );
infoPath->setText( infoPath->text() + item );
} else
sendToServer( Get, infoPath->text() + item );
}
示例2: sendToServer
void LCD::setMusicRepeat(int repeat)
{
if (!m_lcdReady || !m_lcdShowMusic)
return;
sendToServer(QString("SET_MUSIC_PLAYER_PROP REPEAT %1").arg(repeat));
}
示例3: registration
bool registration(string name, string password){
char wiad[49]="";
if(name.length()>20){ cout << "Nazwa za dluga!\n"; return false; }
if(password.length()>20){ cout << "Haslo za dlugie!\n"; return false; }
string whole="register"+name+":"+password;
strcat(wiad, whole.c_str());
sendToServer(wiad);
cout << "Wyslano\n";
//while(1) {
cout << "Oczekiwanie na info od serwera!\n";
if(event.type == ENET_EVENT_TYPE_RECEIVE) {
if(receive(event.packet->data, "GOOD")) {
cout << "REJESTRACJA ZAKONCZONA POMYSLNIE!" << endl;
return true;
//break;
}
else if(receive(event.packet->data, "FAIL")) {
cout << "REJESTRACJA ZAKONCZONA NEGATYWNIE!" << endl;
return false;
//break;
}
}
//}
}
示例4: qDebug
void TcpClientSocket::dataReceived()
{
qDebug()<<"缓冲区现有字节"<<(bytesAvailable());
//按照Demo改
QDataStream in(this);
QString Message;
in.setVersion(QDataStream::Qt_5_5);
quint16 size = 0;
if(size == 0)
{
if(this->bytesAvailable() < sizeof(quint16))
return;
in >> size;
}
if(size == 0xFFFF) return;
if(this->bytesAvailable() < size)
{
qDebug() << size << endl;
return;
}
in >> Message;
QByteArray string1 = Message.toUtf8();
QJsonDocument ParseDocument = QJsonDocument::fromJson(string1);
QJsonObject obj = ParseDocument.object();
qDebug() << obj << endl;
emit sendToServer(this->no,obj);
}
示例5: sendMessageHidden
void sendMessageHidden(string str,string message){
vector<string> temp;
string ret;
//string message;
//cout << "Please enter your message to " << str << " : ";
//getline(cin >> ws,message);
temp.push_back("MSG");
temp.push_back(username);
temp.push_back(str);
temp.push_back(currentDateTime());
temp.push_back(message);
ret = protocolMaker(temp);
if (sendToServer(ret) == 0){
string path = "bin/client/message_history/";
path += username;
path += "-";
path += str;
path += ".txt";
vector<string> data = readExternalFileAutoCreate(path);
data.push_back(ret);
//moveToBottom(path);
//writeExternalFile(path,data);
writeExternalFile2(path,ret); //append data baru aja
}
else{
cout << "Failed to send messages or the user does not exist!" << endl << endl;
}
}
示例6: getNetworkString
/** Sends a vote for the number of tracks from a client to the server. Note
* that even this client will only store the vote when it is received back
* from the server.
* \param player_id The global player id of the voting player.
* \param count NUmber of tracks to play.
*/
void ClientLobbyRoomProtocol::voteRaceCount(uint8_t player_id, uint8_t count)
{
NetworkString *request = getNetworkString(3);
request->addUInt8(LE_VOTE_RACE_COUNT).addUInt8(player_id).addUInt8(count);
sendToServer(request, true);
delete request;
} // voteRaceCount
示例7: sqlite3_client_close
int sqlite3_client_close(sqlite3 *pDb){
SqlMessage msg;
msg.op = MSG_Close;
msg.pDb = pDb;
sendToServer(&msg);
return msg.errCode;
}
示例8: sqlite3_client_finalize
int sqlite3_client_finalize(sqlite3_stmt *pStmt){
SqlMessage msg;
msg.op = MSG_Finalize;
msg.pStmt = pStmt;
sendToServer(&msg);
return msg.errCode;
}
示例9: sendToServer
void Terminal::_prepareHeader(const QString & string)
{
DataHeader head;
head.SetAction(DataHeader::TERMINAL_JOB);
head.setActionSpecs(string);
emit sendToServer(head);
}
示例10: requestFromServer
size_t requestFromServer(const char * request, const size_t requestLen, const size_t hintLength, char ** outputBuffer) {
sendToServer(request, requestLen);
ssize_t requestLength = hintLength > MIN_LENGTH ? hintLength : MIN_LENGTH;
size_t outputLength = 0;
char * output = calloc(sizeof(char), requestLength);
char * readBuffer = calloc(sizeof(char), requestLength);
int done = 0;
while (!done) {
memset(readBuffer, 0, requestLength);
ssize_t charactersRead = read(serverFd, readBuffer, requestLength);
if (charactersRead < 0)
break;
size_t oldOutputLength = outputLength;
outputLength += charactersRead;
if (charactersRead == requestLength) {
requestLength *= 2;
readBuffer = realloc(readBuffer, requestLength);
} else {
done = 1;
}
output = realloc(output, outputLength);
memcpy(output+oldOutputLength, readBuffer, charactersRead);
}
*outputBuffer = output;
free(readBuffer);
return outputLength;
}
示例11: GetMythDB
void LCD::init()
{
// Stop the timer
m_retryTimer->stop();
// Get LCD settings
m_lcdShowMusic = (GetMythDB()->GetSetting("LCDShowMusic", "1") == "1");
m_lcdShowTime = (GetMythDB()->GetSetting("LCDShowTime", "1") == "1");
m_lcdShowChannel = (GetMythDB()->GetSetting("LCDShowChannel", "1") == "1");
m_lcdShowGeneric = (GetMythDB()->GetSetting("LCDShowGeneric", "1") == "1");
m_lcdShowVolume = (GetMythDB()->GetSetting("LCDShowVolume", "1") == "1");
m_lcdShowMenu = (GetMythDB()->GetSetting("LCDShowMenu", "1") == "1");
m_lcdShowRecStatus = (GetMythDB()->GetSetting("LCDShowRecStatus", "1") == "1");
m_lcdKeyString = GetMythDB()->GetSetting("LCDKeyString", "ABCDEF");
m_connected = true;
m_lcdReady = true;
// send buffer if there's anything in there
if (m_sendBuffer.length() > 0)
{
sendToServer(m_sendBuffer);
m_sendBuffer = "";
}
}
示例12: sqlite3_client_reset
int sqlite3_client_reset(sqlite3_stmt *pStmt){
SqlMessage msg;
msg.op = MSG_Reset;
msg.pStmt = pStmt;
sendToServer(&msg);
return msg.errCode;
}
示例13: getNetworkString
// ----------------------------------------------------------------------------
void GameEventsProtocol::sendStartupBoost(uint8_t kart_id)
{
NetworkString *ns = getNetworkString();
ns->setSynchronous(true);
ns->addUInt8(GE_STARTUP_BOOST).addUInt8(kart_id);
sendToServer(ns, /*reliable*/true);
delete ns;
} // sendStartupBoost
示例14: sqlite3_client_open
/*
** The following 6 routines are client-side implementations of the
** core SQLite interfaces:
**
** sqlite3_open
** sqlite3_prepare
** sqlite3_step
** sqlite3_reset
** sqlite3_finalize
** sqlite3_close
**
** Clients should use the following client-side routines instead of
** the core routines above.
**
** sqlite3_client_open
** sqlite3_client_prepare
** sqlite3_client_step
** sqlite3_client_reset
** sqlite3_client_finalize
** sqlite3_client_close
**
** Each of these routines creates a message for the desired operation,
** sends that message to the server, waits for the server to process
** then message and return a response.
*/
int sqlite3_client_open(const char *zDatabaseName, sqlite3 **ppDb){
SqlMessage msg;
msg.op = MSG_Open;
msg.zIn = zDatabaseName;
sendToServer(&msg);
*ppDb = msg.pDb;
return msg.errCode;
}
示例15: login
bool login(string name, string password, CPlayer* player, CCamera* camera){
char wiad[49]="";
if(name.length()>20){ cout << "Name too long!\n"; return false; }
if(password.length()>20){ cout << "Password too long!\n"; return false; }
string whole="login"+name+":"+password;
strcat(wiad, whole.c_str());
player->nick = name;
sendToServer(wiad);
cout << "Sent!\n";
while(1) {
if(event.type == ENET_EVENT_TYPE_RECEIVE) {
if(receive(event.packet->data, "GOOD")) {
cout << "\nLogged!\n" << endl;
string wiad = getPacket(event.packet->data);
string var = "";
int index = 0, what = 0;
for(int i = 5; i < wiad.size()+2; ++i) {
if(wiad[i] != ' ') {
var.resize(var.size()+1);
var[index] = wiad[i];
++index;
}
else {
index = 0;
++what;
if(what == 1) player->hair = atoi(var.c_str());
if(what == 2) player->head = atoi(var.c_str());
if(what == 3) player->body = atoi(var.c_str());
if(what == 4) player->leg = atoi(var.c_str());
if(what == 5) player->boots = atoi(var.c_str());
if(what == 6) player->pos.x = atoi(var.c_str());
if(what == 7) player->pos.y = atoi(var.c_str());
var = "";
}
}
camera->setPos(player->pos.x, player->pos.y);
return true;
}
else if(receive(event.packet->data, "FAIL")) {
cout << "\nError when logging!\n" << endl;
return false;
}
else {
cout << "\nUuu smieci dostaje!\n" << endl;
return false;
}
}
}
}