本文整理汇总了C++中Ref::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ Ref::Count方法的具体用法?C++ Ref::Count怎么用?C++ Ref::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref::Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// This is the entry point into the server (the main() function)
int main() {
// Print starting info to the console
cout << "LL EE EE GG GG OO\n";
cout << "LL EE EE GGG GG OO\n";
cout << "LL EE EE GGG GG OO\n";
cout << "LL EE EE GG G GG OO\n";
cout << "LL EE EE GG G GG OO\n";
cout << "LLLLLL EE EE GG G GG OO\n";
cout << "LLLLLLLL EEEEEE GG GGG OO Server\n";
cout << "\tOriginal project: luniserver.sf.net\n\n\n";
cout << "Initializing LUNI test server...\n \nPress enter type \"help\" and enter again for commands\n\n";
// Initialize the auth, character, and world CONNECT_INFO structs
CONNECT_INFO auth, character, world;
// Load the values for them and store them into their structs
LoadConfig(auth, character, world);
// Create the directory .//logs// if it does not exist
_mkdir("logs");
// If debug is on, print additional data to the console
#ifdef DEBUG
{
cout << "\nDEBUG is ON!\n";
//cout << "\n Minifigure size: " << sizeof(MinifigureData) << endl;
auto testbin = OpenPacket(".\\char\\char_aw2.bin");
//PacketCharacter * pk = (PacketCharacter*) testbin;
/*vector< Ref<Character> > characters(4);
auto aux = (uchar*)testbin.data() +22;
characters[0] = Ref<Character>(new Character(aux));
cout << "\nTest (reading characters form char\\char_aw2.bin) character1 : " << characters[0]->GetName() << endl;
//cout << characters[0]->Data.travelling << endl;
aux += characters[0]->GetGeneratedPacketSize();
characters[1] = Ref<Character>(new Character(aux));
cout << "\nTest character2 : " << characters[1]->GetName() << endl;*/
string s = "ciao";
RakNet::BitStream bs;
bs.WriteCompressed(s);
cout << endl << RawDataToString(bs.GetData(), bs.GetNumberOfBytesUsed()) << endl;
SavePacket("the Test.bin", (char*)bs.GetData(), bs.GetNumberOfBytesUsed());
cout << endl;
}
#endif
// Create the UserPool to store all users by their systemAddress (shared by threads)
Ref< UsersPool > OnlineUsers = new UsersPool();
Ref< CharactersPool > OnlineCharacters = new CharactersPool();
// Create a new CrossThreadQueue for writing output to the console from a thread
Ref< CrossThreadQueue< string > > OutputQueue = new CrossThreadQueue< string >();
// Start the three new threads (Auth, Char, and World servers)
thread thauth(AuthLoop, &auth, OnlineUsers, OutputQueue);
thread thchar(CharactersLoop, &character, OnlineUsers, OnlineCharacters, OutputQueue);
thread thworld(WorldLoop, &world, OnlineUsers, OnlineCharacters, OutputQueue);
// If quit is ever equal to true, quit the server
bool quit = false;
// Keep the server from quitting by using a infinite loop
while (!quit) {
if (OutputQueue->Count() > 0) { // Pop the thread messages
cout << OutputQueue->Pop();
}
if (_kbhit()) { // Parsing server commands. Press enter to start writing a command (may need to lock consoleoutmutex...)
string command; // Initialize command string...
cout << "> "; // Print "> " to show user where to type
cin >> command; // Get the command
cout << endl; // End the line
// Match command to a pre-specified command here...
if (command == "help") cout << "\nAvailable commands: \nquit = Quit the Server \nregister = Register New User \nuser_online = Show Number of Online Users";
else if (command == "quit") quit = LUNIterminate = true;
else if (command == "character_log_enable") character.logFile = true;
else if (command == "character_log_disable") character.logFile = false;
else if (command == "world_log_enable") world.logFile = true;
else if (command == "world_log_disable") world.logFile = false;
else if (command == "user_online") {
cout << "\n Online user: " << OnlineUsers->Count() << endl;
}
else if (command == "register") {
string username, password;
cout << "Username: ";
cin >> username; // Get the username
if (User::FindUserID( username ) == 0) { // Check to see if username already exists... If not, continue
cout << "Password: ";
cin >> password; // Get the password
// Create the new user into the database
Database::Query("INSERT INTO `accounts` (`id`, `name`, `password`, `email`, `ip`, `rank`, `numChars`, `frontChar`, `lastLog`, `activeSub`, `subTime`, `legoClub`, `locked`, `banned`, `loginTries`) VALUES (NULL, '" + username + "', '" + password + "', '', '127.0.0.1', '0', '0', '0', CURRENT_TIMESTAMP, '0', '', '', '0', '0', '0');");
//.........这里部分代码省略.........