bool createAccount(std::string user, std::string password, std::string epr, std::string clientHome) { ClientInfo *clientinfo = new ClientInfo(); clientinfo->setName(user); clientinfo->setSsn("1111"); CreateAccountRequest *request = new CreateAccountRequest(); request->setClientinfo(clientinfo); request->setPassword(password); TraderClientStub *stub = new TraderClientStub(clientHome,epr); if(stub) { CreateAccountResponse *response = stub->createAccount(request); if(response) std::cout<<"RESULTS , Your user id is "<<response->getUserid()<<std::endl; delete stub; return true; } return false; }
bool Game::initialize(ENetAddress *address, const char *baseKey){ if (enet_initialize () != 0) return false; atexit(enet_deinitialize); _server = enet_host_create(address, 32, 0, 0); if(_server == NULL) return false; std::string key = base64_decode(baseKey); if(key.length() <= 0) return false; _blowfish = new BlowFish((uint8*)key.c_str(), 16); initHandlers(); map = new SummonersRift(this); //TODO: better lua implementation LuaScript script(false); script.loadScript("../../lua/config.lua"); // sol::state lua; // lua.open_libraries(sol::lib::base, sol::lib::table); // lua.open_file("../../lua/config.lua"); sol::table playerList = script.getTable("players"); for (int i=1;i<12;i++) { try { std::string playerIndex = "player"+toString(i); sol::table playerData = playerList.get<sol::table>(playerIndex); std::string rank = playerData.get<std::string>("rank"); std::string name = playerData.get<std::string>("name"); std::string champion = playerData.get<std::string>("champion"); std::string team = playerData.get<std::string>("team"); int skin = playerData.get<int>("skin"); int ribbon = playerData.get<int>("ribbon"); int icon = playerData.get<int>("icon"); std::string summoner1 = playerData.get<std::string>("summoner1"); std::string summoner2 = playerData.get<std::string>("summoner2"); ClientInfo* player = new ClientInfo(rank, ((team == "BLUE") ? TEAM_BLUE : TEAM_PURPLE), ribbon, icon); player->setName(name); player->setSkinNo(skin); static int id = 1; player->userId = id; // same as StartClient.bat id++; player->setSummoners(strToId(summoner1), strToId(summoner2)); Champion* c = ChampionFactory::getChampionFromType(champion, map, GetNewNetID(), player->userId); float respawnX, respawnY; std::tie(respawnX, respawnY) = c->getRespawnPosition(); c->setPosition(respawnX, respawnY); c->setSide((team == "BLUE") ? 0 : 1); c->levelUp(); map->addObject(c); player->setChampion(c); players.push_back(player); } catch(sol::error e) { //printf("Error loading champion: \n%s", e.what()); break; } } // Uncomment the following to get 2-players /*ClientInfo* player2 = new ClientInfo("GOLD", TEAM_PURPLE); player2->setName("tseT"); Champion* c2 = ChampionFactory::getChampionFromType("Ezreal", map, GetNewNetID()); c2->setPosition(100.f, 273.55f); c2->setSide(1); map->addObject(c2); player2->setChampion(c2); player2->setSkinNo(4); player2->userId = 2; // same as StartClient.bat player2->setSummoners(SPL_Ignite, SPL_Flash); players.push_back(player2);*/ return _isAlive = true; }
/*! Handle an IPC request. \param aMessage Message object. */ void CServiceSymbianSession::handleRequestL(const RMessage2& aMessage) { XQSERVICE_DEBUG_PRINT("CServiceSymbianSession::handleRequestL"); // Store the message iMessage = aMessage; // Convert from Symbian to QT HBufC* request = ReadDesLC(aMessage, 0); HBufC8* data = ReadDes8LC(aMessage, 1); XQSharableFile *file = 0; if (aMessage.Function() == KIPCOperationWithSharableFile) { // Only one file support now ! file = new XQSharableFile(); AdoptSharableFile(aMessage, file); } // Shallow copy only, we want a deep copy QString d = QString::fromUtf16(request->Ptr(), request->Length()); QString operation; operation += d; XQSERVICE_DEBUG_PRINT("operation: %s", qPrintable(operation)); //QByteArray convertData; TPtr8 ptr8(data->Des()); const char* ptrz = reinterpret_cast<const char*> (ptr8.PtrZ()); //convertData.append(ptrz); QByteArray convertData(ptrz,data->Length()); XQSERVICE_DEBUG_PRINT("convertData: %s", convertData.constData()); // New request if (iCurRequest) { iObserver->handleDeleteRequest(iCurRequest); delete iCurRequest; } iCurRequest = NULL; iCurRequest = new ServiceIPCRequest(this, 0, operation); iData.clear(); // Get client info ClientInfo *client = new ClientInfo(); client->setProcessId(aMessage.SecureId().iId); client->setVendorId(aMessage.VendorId().iId); RThread clientThread; aMessage.ClientL(clientThread); CleanupClosePushL(clientThread); RProcess clientProc; CleanupClosePushL(clientProc); clientThread.Process(clientProc); client->setName(QString::fromUtf16(clientProc.Name().Ptr(), clientProc.Name().Length())); client->setCapabilities(ClientCapabilities(aMessage)); CleanupStack::PopAndDestroy(2, &clientThread); // Set the picked sharable file if any if (file != 0) { // Support only one sharable file iCurRequest->addSharableFile(file, 0); } // Add data and callback to the observer // iCurRequest->addRequestdata(convertData); iCurRequest->setClientInfo(client); // ownership passed iObserver->handleRequest(iCurRequest); CleanupStack::PopAndDestroy(2, request); }