我有以下情况。Client_1 从 Computer_1 中的 Profile_1 开始游戏,登录游戏并开始游戏。Client_2 从 Computer_2 中的 Profile_1 开始游戏,登录游戏并开始游戏。对于 Client_1 蒸汽显示另一个玩家连接的通知,并终止会话。Client_1 如何处理 C++ 代码而不是其他玩家从当前配置文件开始游戏?有回调吗?
问问题
483 次
1 回答
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;
};
}
}
于 2016-04-15T12:39:37.837 回答