本文整理汇总了C++中sendToClient函数的典型用法代码示例。如果您正苦于以下问题:C++ sendToClient函数的具体用法?C++ sendToClient怎么用?C++ sendToClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendToClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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("Сервак ответил")/*отправить сообщение клиенту "бла-бла-бла"*/);
}
}
示例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;
}
}
示例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!");
}
示例9: onQuit
void onQuit() {
if (childPID != 0) {
msgctl(clientQueueID, IPC_RMID, NULL);
sendToClient(serverQueueID, STOP, clientID, 0);
exit(1);
}
}
示例10: sendToClient
void CGalconServer::sendToConnectedClients( const QString& str )
{
for (SocketsMap::iterator it = m_connectedSockets.begin(); it != m_connectedSockets.end(); ++it)
{
sendToClient(it->second, str);
}
}
示例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;
}
示例12: sendToClient
void SrvSocket::sendToAll(std::string message, bool acknowledgeRequired)
{
for(unsigned int i=0; i < _csock.size(); i++)
{
sendToClient(i, message, acknowledgeRequired);
}
}
示例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("Сервак ответил")/*отправить сообщение клиенту "бла-бла-бла"*/);
}
示例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);
}
示例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);
}
}