ServerBrowserCallback

GameSpy SDK

ServerBrowserCallback

The callback provided to ServerBrowserNew. Gets called as the Server Browser updates the server list.

typedef void (*ServerBrowserCallback)(
ServerBrowser sb,
SBCallbackReason reason,
SBServer server,
void * instance );
RoutineRequired HeaderDistribution
ServerBrowserCallback<sb_serverbrowsing.h>SDKZIP

Parameters

sb
[in] The ServerBrowser object the callback is referring to.
reason
[in] The reason for being called. See SDK Doc for more info.
server
[in] The server that is being referred to.
instance
[in] User provided data.

Remarks

"instance" is any game-specific data you want passed to the callback function. For example, you can pass a structure pointer or object pointer for use within the CallBack. If you can access any needed data within the CallBack already, then you can just pass NULL for "instance".

Example


Your callback function should look something like:

void SBCallback(ServerBrowser sb, SBCallbackReason reason, SBServer server, void *instance)
{
CMyGame *g = (CMyGame *)instance;

switch (reason)
{
case sbc_serveradded :
	g->ServerView->AddServerToList(server);
	break;
case sbc_serverupdated : 
	g->ServerView->UpdateServerInList(server);
break;
case sbc_updatecomplete:
	g->ServerView->SetStatus("Update Complete");
	break;
case sbc_queryerror:
g->ServerView->SetStatus("Query Error Occurred:", 
ServerBrowserListQueryError(sb));
	break;
}

}

Example use of the Callback:

int CMyGame::OnMultiplayerButtonClicked(…)
{
    m_ServerBrowser = ServerBrowserNew(“mygame”, ”mygame”, ”123456”, 0, 10,
                                                                QVERSION_QR2, SBCallBack, this);
}

Section Reference: Gamespy Server Browsing SDK

See Also: ServerBrowserNew