本文整理汇总了C++中Lobby类的典型用法代码示例。如果您正苦于以下问题:C++ Lobby类的具体用法?C++ Lobby怎么用?C++ Lobby使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lobby类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
// Pointer to singleton instance
Lobby* lobby = Lobby::Inst();
// Start the server on the given port with the specified maximum number of clients
if (lobby->Start(1337, 100)) {
int delay = 0; // Milliseconds that the server should sleep between updates
int packets; // Number of packets sent and received
// Run until the escape key is pressed
while (!GetAsyncKeyState(VK_ESCAPE)) {
// Call update and incremenent the number of packets
packets = lobby->Update();
// Print the packet count if any
if (packets > 0) {
std::cout << time(NULL) << ": Sent/received " << packets << " packet(s).\n";
delay = 0; // Reset delay any time there is activity to throttle up
}
// Throttle down when no activity is present to free cycles
if (delay < 1000) { // Sleep for no longer than a second
delay += 10;
}
Sleep(delay);
}
lobby->Stop();
}
return 0;
}
示例2: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setFont(QFont("simsun", 9));
dataInterface = new DataInterface;
logic = new Logic;
animation = new Animation;
gui = new GUI;
//FIXME: use ClientUI login and then destroy it
ClientUI c;
#ifdef LOBBY
c.disconnect(&c);
Lobby l;
l.show();
return a.exec();
#else
if(c.exec() == QDialog::Accepted)
{
c.disconnect(&c);
Lobby l;
l.show();
return a.exec();
}
return 0;
#endif
}
示例3: test_addToMessage
void Lobbytest::test_addToMessage()
{
m_lobby->addAccount(new TestAccount());
Atlas::Message::MapType e;
m_lobby->addToMessage(e);
}
示例4: test_addToEntity
void Lobbytest::test_addToEntity()
{
m_lobby->addAccount(new TestAccount());
Atlas::Objects::Entity::RootEntity e;
m_lobby->addToEntity(e);
}
示例5: main
int main( )
{
Lobby myLobby;
int choice;
do
{
cout << myLobby;
cout << "\nGAME LOBBY\n";
cout << "0 - Exit the program.\n";
cout << "1 - Add a player to the lobby.\n";
cout << "2 - Remove a player from the lobby.\n";
cout << "3 - Clear the lobby.\n";
cout << endl << "Enter choice: ";
cin >> choice;
switch( choice )
{
case 0: cout << "Good-bye.\n"; break;
case 1: myLobby.AddPlayer( ); break;
case 2: myLobby.RemovePlayer( ); break;
case 3: myLobby.Clear( ); break;
default: cout << "That was not a valid choice.\n";
}
} while( choice != 0 );
return 0;
}
示例6: test_addAccount
void Lobbytest::test_addAccount()
{
assert(m_lobby->getAccounts().size() == 0);
m_lobby->addAccount(new TestAccount());
assert(m_lobby->getAccounts().size() == 1);
}
示例7: test_delAccount_empty
void Lobbytest::test_delAccount_empty()
{
assert(m_lobby->getAccounts().size() == 0);
m_lobby->delAccount(new TestAccount());
assert(m_lobby->getAccounts().size() == 0);
}
示例8: test_operation_account
void Lobbytest::test_operation_account()
{
Account * tac = new TestAccount();
m_lobby->addAccount(tac);
Atlas::Objects::Operation::RootOperation op;
OpVector res;
op->setTo("2");
m_lobby->operation(op, res);
}
示例9: main
int main(int argc, char *argv[])
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QApplication a(argc, argv);
MainWindow w;
Lobby lobby;
QObject::connect(&lobby, SIGNAL(startGame(QString,qint16)), &w, SLOT(startGame(QString,qint16)));
lobby.show();
return a.exec();
}
示例10: test_addAccount_connected
void Lobbytest::test_addAccount_connected()
{
Account * tac = new TestAccount();
tac->m_connection = new Connection(*(CommSocket*)0,
*(ServerRouting*)0,
"foo", "3", 3);
m_lobby->addAccount(tac);
Atlas::Objects::Operation::RootOperation op;
OpVector res;
m_lobby->operation(op, res);
}
示例11: test_delAccount
void Lobbytest::test_delAccount()
{
assert(m_lobby->getAccounts().size() == 0);
Account * tac = new TestAccount();
m_lobby->addAccount(tac);
assert(m_lobby->getAccounts().size() == 1);
m_lobby->delAccount(tac);
assert(m_lobby->getAccounts().size() == 0);
}
示例12: Init
void LobbyManager::Init(const LobbyManagerConfig config, TcpNet* pNetwork, ILog* pLogger)
{
m_pRefLogger = pLogger;
m_pRefNetwork = pNetwork;
for (int i = 0; i < config.MaxLobbyCount; ++i)
{
Lobby lobby;
lobby.Init((short)i, (short)config.MaxLobbyUserCount, (short)config.MaxRoomCountByLobby, (short)config.MaxRoomUserCount);
lobby.SetNetwork(m_pRefNetwork, m_pRefLogger);
m_LobbyList.push_back(lobby);
}
}
示例13: ABC_WalletServerRepoPost
static
tABC_CC ABC_WalletServerRepoPost(const Lobby &lobby,
DataSlice LP1,
const std::string &szWalletAcctKey,
const char *szPath,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
const auto url = ABC_SERVER_ROOT "/" + std::string(szPath);
HttpReply reply;
ServerReplyJson replyJson;
JsonPtr json(json_pack("{ssssss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
ABC_SERVER_JSON_LP1_FIELD, base64Encode(LP1).c_str(),
ABC_SERVER_JSON_REPO_WALLET_FIELD, szWalletAcctKey.c_str()));
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, url, json.encode()));
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
exit:
return cc;
}
示例14: ABC_LoginServerAvailable
/**
* Queries the server to determine if a username is available.
*/
tABC_CC ABC_LoginServerAvailable(const Lobby &lobby,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
HttpReply reply;
std::string url = ABC_SERVER_ROOT "/" ABC_SERVER_ACCOUNT_AVAILABLE;
ServerReplyJson replyJson;
std::string get;
AccountAvailableJson json;
// create the json
ABC_CHECK_NEW(json.authIdSet(base64Encode(lobby.authId())));
ABC_CHECK_NEW(json.encode(get));
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, url, get));
// decode the result
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
exit:
return cc;
}
示例15: ABC_LoginServerActivate
/**
* Activate an account on the server.
*
* @param LP1 Password hash for the account
*/
tABC_CC ABC_LoginServerActivate(const Lobby &lobby,
tABC_U08Buf LP1,
tABC_Error *pError)
{
tABC_CC cc = ABC_CC_Ok;
HttpReply reply;
std::string url = ABC_SERVER_ROOT "/" ABC_SERVER_ACCOUNT_ACTIVATE;
ServerReplyJson replyJson;
char *szPost = NULL;
json_t *pJSON_Root = NULL;
// create the post data
pJSON_Root = json_pack("{ssss}",
ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
ABC_SERVER_JSON_LP1_FIELD, base64Encode(LP1).c_str());
szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT);
// send the command
ABC_CHECK_NEW(AirbitzRequest().post(reply, url, szPost));
// decode the result
ABC_CHECK_NEW(replyJson.decode(reply.body));
ABC_CHECK_NEW(replyJson.ok());
exit:
ABC_FREE_STR(szPost);
if (pJSON_Root) json_decref(pJSON_Root);
return cc;
}