当前位置: 首页>>代码示例>>C++>>正文


C++ sendToClient函数代码示例

本文整理汇总了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;
}
开发者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


注:本文中的sendToClient函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。