steamworks C ++ sdk。检测客户端已从单个配置文件开始运行游戏

时间:2016-04-08 08:52:23

标签: c++ steam steamworks-api

我有以下的想法。 Client_1从Computer_1中的Profile_1开始游戏,登录游戏,然后玩游戏。 Client_2从Computer_2中的Profile_1开始游戏,登录游戏,然后玩游戏。 对于Client_1蒸汽显示通知,其他玩家连接,并终止会话。 Client_1如何使用当前配置文件处理C ++代码而不是其他玩家启动游戏?有没有回调?

1 个答案:

答案 0 :(得分:0)

确定。我解决了这个问题。这简化了我的实现,允许从steam中监听特定事件。

class SteamCallbacksListener
{
private:
        STEAM_CALLBACK( SteamCallbacksListener, onSteamServersConnected, SteamServersConnected_t, mSteamConnectedListener );
        STEAM_CALLBACK( SteamCallbacksListener, onSteamServersDisconnected, SteamServersDisconnected_t, mSteamDisconnectedListener );
        STEAM_CALLBACK( SteamCallbacksListener, onSteamServerConnectFailure, SteamServerConnectFailure_t, mSteamConnectFilureListener );

         SteamCallbacksListener();
         SteamCallbacksListener( const SteamCallbacksListener& _copy );
        ~SteamCallbacksListener();

public:
        static SteamCallbacksListener* getInstance()
        {
            static SteamCallbacksListener instance;
            return &instance;
        }
};

SteamCallbacksListener::SteamCallbacksListener()
: mSteamConnectedListener( this, &SteamCallbacksListener::onSteamServersConnected )
, mSteamDisconnectedListener( this, &SteamCallbacksListener::onSteamServersDisconnected )
, mSteamConnectFilureListener( this, &SteamCallbacksListener::onSteamServerConnectFailure )
{
}

SteamCallbacksListener::~SteamCallbacksListener()
{
}

void SteamCallbacksListener::onSteamServersConnected( SteamServersConnected_t* _pParam )
{
}

void SteamCallbacksListener::onSteamServersDisconnected( SteamServersDisconnected_t* _pParam )
{
    if( _pParam )
    {
        switch( _pParam->m_eResult )
        {
            case k_EResultAlreadyLoggedInElsewhere:
            case k_EResultLoggedInElsewhere:
            case k_EResultPasswordRequiredToKickSession:
            {
                log( "This client already logged in. Error!" );
            }
            break;
        };
    }
}