本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}