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


C++ IslMessage::set_message_type方法代码示例

本文整理汇总了C++中IslMessage::set_message_type方法的典型用法代码示例。如果您正苦于以下问题:C++ IslMessage::set_message_type方法的具体用法?C++ IslMessage::set_message_type怎么用?C++ IslMessage::set_message_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IslMessage的用法示例。


在下文中一共展示了IslMessage::set_message_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendIsl_GameEventContainer

void Server::sendIsl_GameEventContainer(const GameEventContainer &item, int serverId, qint64 sessionId)
{
    IslMessage msg;
    msg.set_message_type(IslMessage::GAME_EVENT_CONTAINER);
    if (sessionId != -1)
        msg.set_session_id(sessionId);
    msg.mutable_game_event_container()->CopyFrom(item);

    emit sigSendIslMessage(msg, serverId);
}
开发者ID:GuillaumeSeren,项目名称:Cockatrice,代码行数:10,代码来源:server.cpp

示例2: sendIsl_RoomEvent

void Server::sendIsl_RoomEvent(const RoomEvent &item, int serverId, qint64 sessionId)
{
    IslMessage msg;
    msg.set_message_type(IslMessage::ROOM_EVENT);
    if (sessionId != -1)
        msg.set_session_id(sessionId);
    msg.mutable_room_event()->CopyFrom(item);

    emit sigSendIslMessage(msg, serverId);
}
开发者ID:GuillaumeSeren,项目名称:Cockatrice,代码行数:10,代码来源:server.cpp

示例3: sendIsl_Response

void Server::sendIsl_Response(const Response &item, int serverId, qint64 sessionId)
{
    IslMessage msg;
    msg.set_message_type(IslMessage::RESPONSE);
    if (sessionId != -1)
        msg.set_session_id(sessionId);
    msg.mutable_response()->CopyFrom(item);

    emit sigSendIslMessage(msg, serverId);
}
开发者ID:GuillaumeSeren,项目名称:Cockatrice,代码行数:10,代码来源:server.cpp

示例4: sendIsl_RoomCommand

void Server::sendIsl_RoomCommand(const CommandContainer &item, int serverId, qint64 sessionId, int roomId)
{
    IslMessage msg;
    msg.set_message_type(IslMessage::ROOM_COMMAND_CONTAINER);
    msg.set_session_id(sessionId);

    CommandContainer *cont = msg.mutable_room_command();
    cont->CopyFrom(item);
    cont->set_room_id(roomId);

    emit sigSendIslMessage(msg, serverId);
}
开发者ID:GuillaumeSeren,项目名称:Cockatrice,代码行数:12,代码来源:server.cpp

示例5: initServer

void IslInterface::initServer()
{
	socket->setSocketDescriptor(socketDescriptor);
	
	logger->logMessage(QString("[ISL] incoming connection: %1").arg(socket->peerAddress().toString()));
	
	QList<ServerProperties> serverList = server->getServerList();
	int listIndex = -1;
	for (int i = 0; i < serverList.size(); ++i)
		if (serverList[i].address == socket->peerAddress()) {
			listIndex = i;
			break;
		}
	if (listIndex == -1) {
		logger->logMessage(QString("[ISL] address %1 unknown, terminating connection").arg(socket->peerAddress().toString()));
		deleteLater();
		return;
	}
	
	socket->startServerEncryption();
	if (!socket->waitForEncrypted(5000)) {
		QList<QSslError> sslErrors(socket->sslErrors());
		if (sslErrors.isEmpty())
			qDebug() << "[ISL] SSL handshake timeout, terminating connection";
		else
			qDebug() << "[ISL] SSL errors:" << sslErrors;
		deleteLater();
		return;
	}
	
	if (serverList[listIndex].cert == socket->peerCertificate())
		logger->logMessage(QString("[ISL] Peer authenticated as " + serverList[listIndex].hostname));
	else {
		logger->logMessage(QString("[ISL] Authentication failed, terminating connection"));
		deleteLater();
		return;
	}
	serverId = serverList[listIndex].id;
	
	Event_ServerCompleteList event;
	event.set_server_id(server->getServerId());
	
	server->clientsLock.lockForRead();
	QMapIterator<QString, Server_ProtocolHandler *> userIterator(server->getUsers());
	while (userIterator.hasNext())
		event.add_user_list()->CopyFrom(userIterator.next().value()->copyUserInfo(true, true));
	server->clientsLock.unlock();
	
	server->roomsLock.lockForRead();
	QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
	while (roomIterator.hasNext()) {
		Server_Room *room = roomIterator.next().value();
		room->usersLock.lockForRead();
		room->gamesLock.lockForRead();
		room->getInfo(*event.add_room_list(), true, true, false, false);
	}
	
	IslMessage message;
	message.set_message_type(IslMessage::SESSION_EVENT);
	SessionEvent *sessionEvent = message.mutable_session_event();
	sessionEvent->GetReflection()->MutableMessage(sessionEvent, event.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(event);
	
	server->islLock.lockForWrite();
	if (server->islConnectionExists(serverId)) {
		qDebug() << "[ISL] Duplicate connection to #" << serverId << "terminating connection";
		deleteLater();
	} else {
		transmitMessage(message);
		server->addIslInterface(serverId, this);
	}
	server->islLock.unlock();
	
	roomIterator.toFront();
	while (roomIterator.hasNext()) {
		roomIterator.next();
		roomIterator.value()->gamesLock.unlock();
		roomIterator.value()->usersLock.unlock();
	}
	server->roomsLock.unlock();
}
开发者ID:whitshado,项目名称:Cockatrice,代码行数:80,代码来源:isl_interface.cpp


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