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


C++ Event_ConnectionClosed::reason_str方法代码示例

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


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

示例1: processConnectionClosedEvent

void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &event)
{
	client->disconnectFromServer();
	QString reasonStr;
	switch (event.reason()) {
		case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
		case Event_ConnectionClosed::BANNED: {
			reasonStr = tr("Banned by moderator");
			if (event.has_end_time())
				reasonStr.append("\n" + tr("Expected end time: %1").arg(QDateTime::fromTime_t(event.end_time()).toString()));
			else
				reasonStr.append("\n" + tr("This ban lasts indefinitely."));
			if (event.has_reason_str())
				reasonStr.append("\n\n" + QString::fromStdString(event.reason_str()));
			break;
		}
		case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break;
		default: reasonStr = QString::fromStdString(event.reason_str());
	}
	QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
}
开发者ID:Occuliner,项目名称:Cockatrice,代码行数:21,代码来源:window_main.cpp

示例2: processConnectionClosedEvent

void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &event)
{
    client->disconnectFromServer();
    QString reasonStr;
    switch (event.reason()) {
        case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break;
        case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
        case Event_ConnectionClosed::BANNED: {
            reasonStr = tr("Banned by moderator");
            if (event.has_end_time())
                reasonStr.append("\n" + tr("Expected end time: %1").arg(QDateTime::fromTime_t(event.end_time()).toString()));
            else
                reasonStr.append("\n" + tr("This ban lasts indefinitely."));
            if (event.has_reason_str())
                reasonStr.append("\n\n" + QString::fromStdString(event.reason_str()));
            break;
        }
        case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break;
        case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username."); break;
        case Event_ConnectionClosed::LOGGEDINELSEWERE: reasonStr = tr("You have been logged out due to logging in at another location."); break;
        default: reasonStr = QString::fromStdString(event.reason_str());
    }
    QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
}
开发者ID:poixen,项目名称:Cockatrice,代码行数:24,代码来源:window_main.cpp


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