本文整理汇总了C++中sendToClient函数的典型用法代码示例。如果您正苦于以下问题:C++ sendToClient函数的具体用法?C++ sendToClient怎么用?C++ sendToClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendToClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getEntityByAvatarID
bool Scene::playerAttach(ServiceID avatarID, SessionID sID)
{
EntityPtr entity = getEntityByAvatarID(avatarID);
if (!entity)
{
return false;
}
entity->_clientSessionID = sID;
LOGI("Scene::playerAttach avatarName=" << entity->_state.avatarName << " sessionID=" << sID << ", entityID=" << entity->_state.eid);
SceneSectionNotice section;
getSceneSection(section.section);
sendToClient(avatarID, section);
AddEntityNotice notice;
for (auto & e : _entitys)
{
notice.syncs.push_back(e.second->getClientSyncData());
}
if (!notice.syncs.empty())
{
sendToClient(avatarID, notice);
}
onPlayerAttach(entity);
return true;
}
开发者ID:zsummer,项目名称:breeze,代码行数:27,代码来源:scene.cpp
示例2: LOGD
void Scene::onPlayerInstruction(ServiceID avatarID, ReadStream & rs)
{
if (avatarID == InvalidAvatarID)
{
return;
}
if (rs.getProtoID() == MoveReq::getProtoID())
{
MoveReq req;
rs >> req;
LOGD("MoveReq avatarID[" << avatarID << "] req=" << req);
auto entity = getEntity(req.eid);
if (!entity || entity->_state.avatarID != avatarID || entity->_state.etype != ENTITY_PLAYER
|| (req.action != MOVE_ACTION_IDLE && req.action == MOVE_ACTION_FOLLOW && req.action == MOVE_ACTION_PATH)
|| entity->_state.state != ENTITY_STATE_ACTIVE
)
{
sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action));
return;
}
if (!_move->doMove(req.eid, (MOVE_ACTION)req.action, entity->getSpeed(), req.follow, req.waypoints))
{
sendToClient(avatarID, MoveResp(EC_ERROR, req.eid, req.action));
return;
}
if (entity->_skillSys.combating)
{
entity->_skillSys.combating = false;
}
}
开发者ID:zsummer,项目名称:breeze,代码行数:31,代码来源:scene.cpp
示例3: sendToClient
void MainWindow::colorChange(QString& newColor)
{
QTcpSocket *clientTcpSocket = (QTcpSocket*)sender();
if ((color==newColor) | ((newColor!="green") & (newColor!="blue") & (newColor!="red")) | (state=="off")) {
messageTo = "FAILED\n";
sendToClient(clientTcpSocket,messageTo);
return;
}
color=newColor;
repaint();
messageTo = "OK\n";
sendToClient(clientTcpSocket,messageTo);
}
开发者ID:Veala,项目名称:Led,代码行数:13,代码来源:mainwindow.cpp
示例4: main
int main(int argc, char* argv[]) {
int port;
int serverSocket, clientSocket;
struct httpParams httpParam;
system("clear");
if (argc != 2) {
fprintf(stderr, "Usage: %s <Server Port>\n", argv[0]);
exit(1);
}
port = atoi(argv[1]);
serverSocket = initializeServer(port);
while(1) {
clientSocket = getRequest(serverSocket);
readFromClient(clientSocket);
httpParam = prepareGetQuery();
sendToClient(clientSocket, httpParam);
exit(1);
}
}
开发者ID:VivekKSingh,项目名称:QRCODESCANNER,代码行数:28,代码来源:server.c
示例5: in
void Server::slotReadClient()
{
QTcpSocket* pClientSocket = (QTcpSocket*)sender();
QDataStream in(pClientSocket);
//in.setVersion(QDataStream::Qt_4_8);
for(;;)
{
if (!NextBlockSize)
{
if (pClientSocket->bytesAvailable() < sizeof(quint16)) break;
in >> NextBlockSize;
}
if (pClientSocket->bytesAvailable() < NextBlockSize) break;
QTime time;
QString str;
in >> time >> str;
QString strMessage = time.toString() + " " + "Client has sent - " + str;
//ptxt->append(strMessage);
emit signal_display(strMessage);
NextBlockSize = 0;
str = "Server Response: Recived " + str + "/";
QString *pstr = &str;
sendToClient(pClientSocket, *pstr);
}
}
开发者ID:lishmael,项目名称:kursach_4,代码行数:25,代码来源:server.cpp
示例6: in
//получаем сообщения от клиента
void InformerTCPServer::slotReadClient()
{
QTcpSocket *pClientSocket = (QTcpSocket*)sender();
QDataStream in(pClientSocket);
in.setVersion(QDataStream::Qt_4_8);
for(;;){
if(!m_nNextBlockSize){
if(pClientSocket->bytesAvailable() < sizeof(quint16))
break;
}
in >> m_nNextBlockSize;
if (pClientSocket->bytesAvailable() < m_nNextBlockSize) {
break;
}
QTime time;
QString str;
in >> time >> str; //записываем сообщения от клиента
//time записываем себе в лог, например
//str пишем туда же
m_nNextBlockSize = 0; //обнуляем счетчик байт
sendToClient(pClientSocket, trUtf8("Сервак ответил")/*отправить сообщение клиенту "бла-бла-бла"*/);
}
}
开发者ID:OlegGrRus,项目名称:informer,代码行数:26,代码来源:informertcpserver.cpp
示例7: data
void Server::slotReadClient()
{
QTcpSocket* pClientSocket = (QTcpSocket*)sender();
QDataStream data(pClientSocket);
data.setVersion(QDataStream::Qt_5_4);
QString buf;
qint16 nextBlockSize = 0;
for(;;)
{
if(!nextBlockSize)
{
if(pClientSocket->bytesAvailable() < sizeof(qint16))
break;
data >> nextBlockSize;
}
if(pClientSocket->bytesAvailable() < nextBlockSize)
break;
data >> buf;
if(!buf.isEmpty())
sendToClient(pClientSocket, scanner.scanFile(buf));
nextBlockSize = 0;
}
}
开发者ID:MaximBobuh,项目名称:Signatures-Detector,代码行数:29,代码来源:server.cpp
示例8: connect
void MainWindow::newConnection()
{
QTcpSocket* clientTcpSocket = tcpServer->nextPendingConnection();
connect(clientTcpSocket, SIGNAL(disconnected()), clientTcpSocket, SLOT(deleteLater()));
connect(clientTcpSocket, SIGNAL(readyRead()), this, SLOT(readClient()));
sendToClient(clientTcpSocket, "Server Response: Connected!");
}
开发者ID:Veala,项目名称:Led,代码行数:7,代码来源:mainwindow.cpp
示例9: onQuit
void onQuit() {
if (childPID != 0) {
msgctl(clientQueueID, IPC_RMID, NULL);
sendToClient(serverQueueID, STOP, clientID, 0);
exit(1);
}
}
开发者ID:Ajris,项目名称:sysopy,代码行数:7,代码来源:client.c
示例10: sendToClient
void CGalconServer::sendToConnectedClients( const QString& str )
{
for (SocketsMap::iterator it = m_connectedSockets.begin(); it != m_connectedSockets.end(); ++it)
{
sendToClient(it->second, str);
}
}
开发者ID:TeamFirst,项目名称:Galcon,代码行数:7,代码来源:galconserver.cpp
示例11: getUserEntity
bool Scene::enterScene(ServiceID avatarID, const std::string & token, SessionID sID)
{
EntityPtr entity = getUserEntity(avatarID);
if (!entity)
{
return false;
}
if (entity->_token != token)
{
return false;
}
entity->_clientSessionID = sID;
if (!getEntity(entity->_info.eid))
{
addEntity(entity);
}
FillSceneNotice notice;
EntityFullInfo info;
for (auto kv : _entitys)
{
kv.second->pickProto(info);
notice.entitys.push_back(info);
}
notice.serverTime = getFloatNowTime();
notice.sceneStartTime = _startTime;
notice.sceneEndTime = _endTime;
sendToClient(avatarID, notice);
return true;
}
开发者ID:theone-pang,项目名称:breeze,代码行数:29,代码来源:scene.cpp
示例12: sendToClient
void SrvSocket::sendToAll(std::string message, bool acknowledgeRequired)
{
for(unsigned int i=0; i < _csock.size(); i++)
{
sendToClient(i, message, acknowledgeRequired);
}
}
开发者ID:yanndanielou,项目名称:yanndanielou-programmation,代码行数:7,代码来源:SrvSocket.cpp
示例13: connect
//создаем сокет для соединения клиентов
void InformerTCPServer::slotNewConnection()
{
QTcpSocket *pClientSocket = m_ptcpServer->nextPendingConnection();
connect(pClientSocket, SIGNAL(disconnected()), pClientSocket, SLOT(deleteLater()));
connect(pClientSocket, SIGNAL(readyRead()),this, SLOT(slotReadClient()));
sendToClient(pClientSocket, trUtf8("Сервак ответил")/*отправить сообщение клиенту "бла-бла-бла"*/);
}
开发者ID:OlegGrRus,项目名称:informer,代码行数:8,代码来源:informertcpserver.cpp
示例14: addPositionAndDirectionToStream
//-------------------------------------------------------------------------------------
void Proxy::initClientCellPropertys()
{
if(getClientMailbox() == NULL)
return;
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
(*pBundle).newMessage(ClientInterface::onUpdatePropertys);
(*pBundle) << this->getID();
ENTITY_PROPERTY_UID spaceuid = ENTITY_BASE_PROPERTY_UTYPE_SPACEID;
Mercury::FixedMessages::MSGInfo* msgInfo =
Mercury::FixedMessages::getSingleton().isFixed("Property::spaceID");
if(msgInfo != NULL)
{
spaceuid = msgInfo->msgid;
}
(*pBundle) << spaceuid << this->getSpaceID();
MemoryStream* s = MemoryStream::ObjPool().createObject();
addPositionAndDirectionToStream(*s);
(*pBundle).append(s);
MemoryStream::ObjPool().reclaimObject(s);
// celldata获取客户端感兴趣的数据初始化客户端 如:ALL_CLIENTS
s = MemoryStream::ObjPool().createObject();
addCellDataToStream(ED_FLAG_ALL_CLIENTS|ED_FLAG_CELL_PUBLIC_AND_OWN|ED_FLAG_OWN_CLIENT, s);
(*pBundle).append(*s);
MemoryStream::ObjPool().reclaimObject(s);
//getClientMailbox()->postMail((*pBundle));
//Mercury::Bundle::ObjPool().reclaimObject(pBundle);
sendToClient(ClientInterface::onUpdatePropertys, pBundle);
}
开发者ID:gongjiji,项目名称:kbengine,代码行数:36,代码来源:proxy.cpp
示例15: LOG
void Worker::onBackendResponse(Backend *backend)
{
LOG("backend response");
Buffer &resp = backend->getResponse();
Connection *client = backend->getClient();
if(client && resp.size()){
sendToClient(client, &resp);
}
}
开发者ID:luozy,项目名称:fooking,代码行数:9,代码来源:Worker.cpp
示例16: sendToClient
void SessionOp::sendDisconnectToClient()
{
DisconnectMsg_SN msg;
auto& fields = msg.fields();
auto& durationField = std::get<decltype(msg)::FieldIdx_duration>(fields);
durationField.setMode(comms::field::OptionalMode::Missing);
sendToClient(msg);
}
开发者ID:arobenko,项目名称:mqtt-sn,代码行数:9,代码来源:SessionOp.cpp
示例17: htonl
void Server::sendLongArray(std::vector<int> arr)
{
uint32_t *arr_raw = new uint32_t[(size_t)arr.size()];
for (size_t i = 0; i < arr.size(); ++i) {
arr_raw[i] = htonl((uint32_t)arr[i]);
}
sendToClient(arr_raw, sizeof(uint32_t) * arr.size());
delete [] arr_raw;
}
开发者ID:aspotashev,项目名称:stupid-ids,代码行数:10,代码来源:server.cpp
示例18: sendToClient
// send data to all clients
void ServerNetworkManager::sendToAll(unsigned int iteration, unsigned int packet_type, unsigned int object_id, CommandTypes command_type, unsigned int data_size) {
SOCKET currentSocket;
std::map<unsigned int, SOCKET>::iterator iter;
int iSendResult;
for (iter = sessions.begin(); iter != sessions.end(); iter++) {
currentSocket = iter->second;
iSendResult = sendToClient(currentSocket, iteration, packet_type, object_id, command_type, data_size);
}
}
开发者ID:Sudoka,项目名称:NinjaCoders125,代码行数:11,代码来源:ServerNetworkManager.cpp
示例19: sendToClient
void MessageWidget::sendSms(QString number,QString message)
{
if (number.contains('('))
{
number.chop(1);
number = number.mid(number.indexOf("(")+1,number.length());
}
sendToClient("SEND_SMS:"+number.toLatin1()+":"+message.toLatin1());
//addSMS(, "1",QString::number(QDateTime::currentMSecsSinceEpoch()),number,"1","outbox",message);
}
开发者ID:Smeat,项目名称:QtAdb,代码行数:11,代码来源:messagewidget.cpp
示例20: main
int main(int argc, char **argv) {
text = malloc(MAX_MESSAGE_LEN);
if ((serverQueueID = msgget(ftok(getenv("HOME"), 0), 0)) == -1)
printError("Coudlnt get server queue");
if ((clientQueueID = msgget(ftok(getenv("HOME"), getpid()), IPC_CREAT | 0666)) == -1)
printError("Coudlnt get client queue");
atexit(onQuit);
sendToClient(serverQueueID, INIT, ftok(getenv("HOME"), getpid()), 0);
Message message = receiveData(clientQueueID);
clientID = message.value;
printf("ID: %d\n", clientID);
if ((childPID = fork()) == 0) {
while (1) {
Message received = receiveData(clientQueueID);
if (received.type == ECHO){
printf("GOT MESSAGE ECHO: %s\n", received.text);
printf("-------------\n");
}
if (received.type == STOP) {
printf("GOT MESSAGE STOP");
kill(getppid(), SIGUSR1);
exit(0);
}
}
} else {
signal(SIGINT, handleCtrlC);
signal(SIGUSR1, handleSIGUSR);
char *comm = malloc(MAX_MESSAGE_LEN);
if (argc > 2) {
FILE *fd;
if(strcmp(argv[1], "READ") != 0)
printError("NOT READ?");
if ((fd = fopen(argv[2], "r")) != NULL) {
char *input = malloc(MAX_FILE_SIZE);
fread(input, sizeof(char), MAX_FILE_SIZE, fd);
comm = strtok(input, "\n");
while (comm != NULL) {
handleInput(comm, strlen(comm));
comm = strtok(NULL, "\n");
}
}
}
size_t MAX_MESSAGE_LEN_SIZE_T = MAX_MESSAGE_LEN + 6;
while (1) {
size_t size = getline(&comm, &MAX_MESSAGE_LEN_SIZE_T, stdin);
handleInput(comm, size);
}
}
}
开发者ID:Ajris,项目名称:sysopy,代码行数:54,代码来源:client.c
注:本文中的sendToClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论