/**
 *  verarbeitet die Register-Nachricht eines Clients.
 *
 *  @param[in] message Nachricht, welche ausgeführt wird
 *  @param[in] client  die Nummer des Clients
 *
 *  @author FloSoft
 */
void LobbyServer::OnNMSLobbyRegister(unsigned int id, const unsigned int revision, const std::string& user, const std::string& pass, const std::string& email)
{
    LobbyPlayer& player = players[id];

    // Protokollversion prüfen
    if(!CheckProtocolVersion(revision, user, player))
        return;

    /*if(MYSQLCLIENT.RegisterUser(user, pass, email))
    {
        LOG.write(("User %s registered\n", user);

        player.Send(new LobbyMessage_Register_Done(1));
    }
    else
    {
        LOG.write(("User %s failed to register\n", user);

        player.Send(new LobbyMessage_Register_Error("Registrierung fehlgeschlagen: Datenbankfehler oder Benutzer existiert schon"));

        Disconnect(player);
    }*/
    LOG.write("User %s tried to register\n") % user;

    player.Send(new LobbyMessage_Register_Error("To register, you have to create a valid board account at\nhttp://forum.siedler25.org\nat the moment.\n"));

    Disconnect(player);
}
Esempio n. 2
0
void CDataFeed::VGetSupportedSymbols(const CFxEventInfo& eventInfo, const vector<CFxSymbolInfo>& symbols)
{
	if (eventInfo.IsInternalAsynchCall())
	{
		m_cache.UpdateSymbols(symbols);

        if (!CheckProtocolVersion(CProtocolVersion(1, 24)))
        {
            map<string, CFxCurrencyInfo> currenciesMap;

            for (const auto& s : symbols)
            {
                if (currenciesMap.find(s.Currency) == currenciesMap.end())
                    currenciesMap[s.Currency] = CFxCurrencyInfo(s.Currency, "", s.CurrencySortOrder, s.CurrencyPrecision);

                if (currenciesMap.find(s.SettlementCurrency) == currenciesMap.end())
                    currenciesMap[s.SettlementCurrency] = CFxCurrencyInfo(s.SettlementCurrency, "", s.SettlementCurrencySortOrder, s.SettlementCurrencyPrecision);
            }

            vector<CFxCurrencyInfo> currencies;

            for (const auto& c : currenciesMap)
            {
                currencies.push_back(c.second);
            }

            m_cache.UpdateCurrencies(currencies);
        }
	}
	__super::VGetSupportedSymbols(eventInfo, symbols);
}
Esempio n. 3
0
vector<CFxCurrencyInfo> CDataFeed::GetCurrencies(uint32 timeoutInMilliseconds)
{
    if (!CheckProtocolVersion(CProtocolVersion(1, 24)))
    {
        throw CUnsupportedFeatureException(cUnsupportedFeature, "GetCurrencies");
    }

    Waiter<vector<CFxCurrencyInfo> > waiter(timeoutInMilliseconds, cExternalSynchCall, *this);
    m_sender->VSendGetCurrencies(waiter.Id());

    vector<CFxCurrencyInfo> result = waiter.WaitForResponse();
    return result;
}
Esempio n. 4
0
void CDataFeed::VNotify(const CFxEventInfo& eventInfo, const CNotification& notification)
{
    if (NotificationType_ConfigUpdated == notification.Type)
    {
	    string id = NextId(cInternalASynchCall);
	    m_sender->VSendGetSupportedSymbols(id);

        if (CheckProtocolVersion(CProtocolVersion(1, 24)))
        {
            id = NextId(cInternalASynchCall);
            m_sender->VSendGetCurrencies(id);
        }

    }
    __super::VNotify(eventInfo, notification);
}
Esempio n. 5
0
void CDataFeed::VLogon(const CFxEventInfo& eventInfo, const string& protocolVersion)
{
	__super::VLogon(eventInfo, protocolVersion);

	ResetEvent(m_serverQuotesHistoryEvent);
	m_cache.Clear();

	string id = NextId(cInternalASynchCall);
	m_sender->VSendGetSupportedSymbols(id);

    if (CheckProtocolVersion(CProtocolVersion(1, 24)))
    {
        id = NextId(cInternalASynchCall);
        m_sender->VSendGetCurrencies(id);
    }

	id = NextId(cInternalASynchCall);
	m_sender->VSendQuotesHistoryRequest(id);
}
/**
 *  verarbeitet die Login-Nachricht eines Clients.
 *
 *  @param[in] message Nachricht, welche ausgeführt wird
 *  @param[in] client  die Nummer des Clients
 *
 *  @author FloSoft
 */
void LobbyServer::OnNMSLobbyLogin(unsigned int id, const unsigned int revision, const std::string& user, const std::string& pass, const std::string& version)
{
    LobbyPlayer& player = players[id];

    // Protokollversion prüfen
    if(!CheckProtocolVersion(revision, user, player))
        return;

    std::string email;
    if(MYSQLCLIENT.LoginUser(user, pass, email, player.getPeerIP()))
    {
        LobbyPlayer* oldPlayer = GetPlayer(user);
        if(oldPlayer && oldPlayer->isLoggedIn())
        {
            LOG.write("User %s@%s already logged on (slot %d == %d)!\n") % user % player.getPeerIP() % id % oldPlayer->getId();
            player.Send(new LobbyMessage_Login_Error("Already logged in. On connection loss just wait a bit then try again."));
            // alten Spieler rauswerfen
            Disconnect(*oldPlayer);
        } else
        {
            LOG.write("User %s@%s logged on\n") % user % player.getPeerIP();

            player.occupy(user, email, version);
            player.Send(new LobbyMessage_Login_Done(email));

            SendToAll(LobbyMessage_Chat("SYSTEM", user + " hat die Lobby betreten"));

            SendServerList(0xFFFFFFFF);
            SendPlayerList(0xFFFFFFFF);
        }
    }
    else
    {
        LOG.write("User %s invalid (password %s wrong?)\n") % user % "********";
        player.Send(new LobbyMessage_Login_Error("User/password combination is unknown!"));
        Disconnect(player);
    }
}