chatConnect

GameSpy SDK

chatConnect

The chatConnect function initializes the Chat SDK and initiates a connection to the chat server.

CHAT chatConnect(
const gsi_char * serverAddress,
int port,
const gsi_char * nick,
const gsi_char * user,
const gsi_char * name,
chatGlobalCallbacks * callbacks,
chatNickErrorCallback nickErrorCallback,
chatConnectCallback connectCallback,
void * param,
CHATBool blocking );
RoutineRequired HeaderDistribution
chatConnect<chat.h>SDKZIP

Return Value

This function returns the initialized Chat SDK interface. A return value of NULL indicates an error.

Parameters

serverAddress
[in] Address of the chat server being connect to; usually "peerchat.gamespy.com".
port
[in] Port of the chat server; usually 6667.
nick
[in] Nickname in use while chatting. Not associated with a user account in any way.
user
[in] User’s username
name
[in] User’s real name, or any other optional info.
callbacks
[in] Structure for specifying global handlers.
nickErrorCallback
[in] Optional user-supplied function to be called if nickname is invalid or in use.
connectCallback
[in] Optional user-supplied function to be called when the operation has completed.
param
[in] Optional pointer to user data; will be passed unmodified to the callback function.
blocking
[in] If CHATTrue, return only after the operation has completed; otherwise, return immediately.

Remarks

The server address and port for the connect functions can be left empty. In other words, serverAddress can be NULL, and the port can be specified to be 0. The SDK will automatically take care of using the default address and port.

Unicode Mappings

RoutineGSI_UNICODE Not DefinedGSI_UNICODE Defined
chatConnectchatConnectAchatConnectW

chatConnectW and chatConnectA are UNICODE and ANSI mapped versions of chatConnect. The arguments of chatConnectA are ANSI strings; those of chatConnectW are wide-character strings.

Example

int CMyGame::OnConnect(…)
{

    m_chat = chatConnect(“irc.mygame.com”, 6667, “nick”, “user”, “[email protected]”, &callbacks;, callback, this, CHATFalse);
    if (m_chat == NULL)
            Error();

}