OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
peer.h
1 /*
2GameSpy Peer SDK
3Dan "Mr. Pants" Schoenblum
4dan@gamespy.com
5
6Copyright 1999-2007 GameSpy Industries, Inc
7
8devsupport@gamespy.com
9*/
10
11#ifndef _PEER_H_
12#define _PEER_H_
13
14/*************
15** INCLUDES **
16*************/
17#include "../common/gsCommon.h"
18#include "../Chat/chat.h"
19#include "../qr2/qr2.h"
20#include "../serverbrowsing/sb_internal.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/************
27** DEFINES **
28************/
29// Defines for the msg param that's passed into peerListingGamesCallback().
30// PANTS-04.20.00-changed from PI_* to PEER_*
31// PANTS-09.26.02-added PEER_COMPLETE
33#define PEER_ADD 0 // a server is being added
34#define PEER_UPDATE 1 // a server has been updated
35#define PEER_REMOVE 2 // a server has been removed
36#define PEER_CLEAR 3 // all the servers have been cleared
37#define PEER_COMPLETE 4 // the initial listing of servers is complete
38
39// Nick errors, for peerNickErrorCallback.
41#define PEER_NICK_OK 0
42#define PEER_IN_USE 1 // the nick is already being used
43#define PEER_INVALID 2 // the nick contains invalid characters
44#define PEER_UNIQUENICK_EXPIRED 3 // the uniquenick for this account has expired
45#define PEER_NO_UNIQUENICK 4 // there is no uniquenick for this account
46#define PEER_INVALID_UNIQUENICK 5 // the uniquenick to associate with the account is invalid or in use
47#define PEER_NICK_TOO_LONG 6 // the nick was too long
48
49// Possible values for the failureReason passed to the peerConnectCallback.
51#define PEER_DISCONNECTED 0 // disconnected from, or unable to connect to, the server
52#define PEER_NICK_ERROR 1 // a nick error was either ignored or not handled
53#define PEER_LOGIN_FAILED 2 // the login info passed to peerConnectLogin was not valid
54
55// Maximum length of a room password, including the terminating NUL.
57#define PEER_PASSWORD_LEN 24
58
59// Each player can have various flags set for each room they are in.
61#define PEER_FLAG_STAGING 0x01 // s
62#define PEER_FLAG_READY 0x02 // r
63#define PEER_FLAG_PLAYING 0x04 // g
64#define PEER_FLAG_AWAY 0x08 // a
65#define PEER_FLAG_HOST 0x10 // h
66#define PEER_FLAG_OP 0x20
67#define PEER_FLAG_VOICE 0x40
68
69// Bitfield reporting options for peerStartGame.
71#define PEER_KEEP_REPORTING 0 // Continue reporting.
72#define PEER_STOP_REPORTING 1 // Stop reporting. Cannot be used with other options.
73#define PEER_REPORT_INFO 2 // Continue reporting server keys (as if it were not playing).
74#define PEER_REPORT_PLAYERS 4 // Continue reporting player keys (as if it were not playing).
75
76/**********
77** TYPES **
78**********/
79// The peer object.
81typedef void * PEER;
82
83// Boolean.
85typedef enum
86{
87 PEERFalse,
88 PEERTrue
89} PEERBool;
90
91// Types of rooms.
93typedef enum
94{
95 TitleRoom, // The main room for a game.
96 GroupRoom, // A room which is, in general, for a particular type of gameplay (team, dm, etc.).
97 StagingRoom, // A room where players meet before starting a game.
98 NumRooms
99} RoomType;
100
101// Types of messages. These have the same
102// values as their CHAT SDK counterparts.
103// PANTS-01.08.01
105typedef enum
106{
107 NormalMessage,
108 ActionMessage,
109 NoticeMessage
110} MessageType;
111
112// Possible results when attempting to join a room.
113// Passed into peerJoinRoomCallback().
115typedef enum
116{
117 PEERJoinSuccess, // The room was joined.
118
119 PEERFullRoom, // The room is full.
120 PEERInviteOnlyRoom, // The room is invite only.
121 PEERBannedFromRoom, // The local user is banned from the room.
122 PEERBadPassword, // An incorrect password (or none) was given for a passworded room.
123
124 PEERAlreadyInRoom, // The local user is already in or entering a room of the same type.
125 PEERNoTitleSet, // Can't join a room if no title is set.
126 PEERNoConnection, // Can't join a room if there's no chat connection.
127 PEERAutoMatching, // The user can't join a staging room during an auto match attempt.
128
129 PEERJoinFailed // Generic failure.
130} PEERJoinResult;
131
132// Possible status values passed to the peerAutoMatchStatusCallback.
133// If PEERFailed, the match failed, otherwise this is the current status
134// of the automatch attempt.
136typedef enum
137{
138 PEERFailed, // The automatch attempt failed.
139
140 PEERSearching, // Searching for a match (active).
141 PEERWaiting, // Waiting for a match (passive).
142 PEERStaging, // In a staging room with at least one other player, possibly waiting for more.
143 PEERReady, // All players are in the staging room, the game is ready to be launched.
144 PEERComplete // The game is launching, the automatch attempt is now complete.
145 // The player is still in the staging room.
146} PEERAutoMatchStatus;
147
148/**************
149** CALLBACKS **
150**************/
151// Called when the connection to the server gets disconnected.
153typedef void (* peerDisconnectedCallback)
154(
155 PEER peer, // The peer object.
156 const gsi_char * reason, // The reason for the disconnection.
157 void * param // User-data.
158);
159
160// Called when a message is sent to a room the local player is in.
162typedef void (* peerRoomMessageCallback)
163(
164 PEER peer, // The peer object.
165 RoomType roomType, // The type of room that the message was in.
166 const gsi_char * nick, // The nick of the player who sent the message.
167 const gsi_char * message, // The text of the message.
168 MessageType messageType, // The type of message.
169 void * param // User-data.
170);
171
172// Called when a UTM is sent to a room the local player is in.
174typedef void (* peerRoomUTMCallback)
175(
176 PEER peer, // The peer object.
177 RoomType roomType, // The type of room that the UTM was in.
178 const gsi_char * nick, // The nick of the player who sent the UTM.
179 const gsi_char * command, // The UTM command for this message.
180 const gsi_char * parameters, // Any parameters for this UTM.
181 PEERBool authenticated, // True if this has been authenticated by the server.
182 void * param // User-data.
183);
184
185// Called when the name of a room the player is in changes.
186// The new name can be checked with peerGetRoomName.
187// PANTS|09.11.00
189typedef void (* peerRoomNameChangedCallback)
190(
191 PEER peer, // The peer object.
192 RoomType roomType, // The type of room that the name changed in.
193 void * param // User-data
194);
195
196// Called when a room's mode changes.
197// PANTS|04.17.00
199typedef void (* peerRoomModeChangedCallback)
200(
201 PEER peer, // The peer object.
202 RoomType roomType, // The type of room that the name changed in.
203 CHATChannelMode * mode, // The current mode for this room.
204 void * param // User-data
205);
206
207// Called when a private message is received from another player.
209typedef void (* peerPlayerMessageCallback)
210(
211 PEER peer, // The peer object.
212 const gsi_char * nick, // The nick of the player who sent the message.
213 const gsi_char * message, // The text of the message.
214 MessageType messageType, // The type of message.
215 void * param // User-data
216);
217
218// Called when a private UTM is received from another player.
220typedef void (* peerPlayerUTMCallback)
221(
222 PEER peer, // The peer object.
223 const gsi_char * nick, // The nick of the player who sent the UTM.
224 const gsi_char * command, // The UTM command for this message.
225 const gsi_char * parameters, // Any parameters for this UTM.
226 PEERBool authenticated, // True if this has been authenticated by the server.
227 void * param // User-data
228);
229
230// Called when a player's ready state changes,
231// from a call to peerSetReady().
233typedef void (* peerReadyChangedCallback)
234(
235 PEER peer, // The peer object.
236 const gsi_char * nick, // The nick of the player who's ready state changed.
237 PEERBool ready, // The player's new ready state.
238 void * param // User-data.
239);
240
241// Called when the host of a staging room launches the game,
242// with a call to peerStartGame().
243// The public and private IPs and ports of the server can
244// be obtained from the server object.
246typedef void (* peerGameStartedCallback)
247(
248 PEER peer, // The peer object.
249 SBServer server, // A server object representing this host.
250 const gsi_char * message, // A message that was passed into peerStartGame().
251 void * param // User-data.
252);
253
254// A player joined a room.
256typedef void (* peerPlayerJoinedCallback)
257(
258 PEER peer, // The peer object.
259 RoomType roomType, // The type of room that the player joined.
260 const gsi_char * nick, // The nick of the player that joined.
261 void * param // User-data.
262);
263
264// A player left a room.
266typedef void (* peerPlayerLeftCallback)
267(
268 PEER peer, // The peer object.
269 RoomType roomType, // The type of room that the player left.
270 const gsi_char * nick, // The nick of the player that left.
271 const gsi_char * reason, // The reason the player left.
272 void * param // User-data.
273);
274
275// The local player was kicked from a room.
277typedef void (* peerKickedCallback)
278(
279 PEER peer, // The peer object.
280 RoomType roomType, // The type of room that the player was kicked from.
281 const gsi_char * nick, // The nick of the player that did the kicking.
282 const gsi_char * reason, // An optional reason for the kick.
283 void * param // User-data.
284);
285
286// The entire player list for this room has been updated.
288typedef void (* peerNewPlayerListCallback)
289(
290 PEER peer, // The peer object.
291 RoomType roomType, // The type of room.
292 void * param // User-data
293);
294
295// A player in one of the rooms changed his nick.
297typedef void (* peerPlayerChangedNickCallback)
298(
299 PEER peer, // The peer object.
300 RoomType roomType, // The type of the room the nick changed was in.
301 const gsi_char * oldNick, // The player's old nick.
302 const gsi_char * newNick, // The player's new nick.
303 void * param // User-data.
304);
305
306// The IP and ProfileID for this player has just been received.
307// PANTS|01.08.01
308// This gets called for all players (who are using peer) in a room
309// shortly after joining. It will be called with nick==NULL after
310// getting info for all the players.
312typedef void (* peerPlayerInfoCallback)
313(
314 PEER peer, // The peer object.
315 RoomType roomType, // The room the info was gotten in.
316 const gsi_char * nick, // The nick of the player the info is for.
317 unsigned int IP, // The player's IP.
318 int profileID, // The player's profile ID.
319 void * param // User-data.
320);
321
322// This gets called when a player's flags have changed.
324typedef void (* peerPlayerFlagsChangedCallback)
325(
326 PEER peer, // The peer object.
327 RoomType roomType, // The room the flags were changed in.
328 const gsi_char * nick, // The player whose flags have changed.
329 int oldFlags, // The player's old flags.
330 int newFlags, // The player's new flags.
331 void * param // User-data
332);
333
334// An updated ping for a player, who may be in any room(s).
336typedef void (* peerPingCallback)
337(
338 PEER peer, // The peer object.
339 const gsi_char * nick, // The other player's nick.
340 int ping, // The ping.
341 void * param // User-data.
342);
343
344// An updated cross-ping between two players in the staging room.
346typedef void (* peerCrossPingCallback)
347(
348 PEER peer, // The peer object.
349 const gsi_char * nick1, // The first player's nick.
350 const gsi_char * nick2, // The second player's nick.
351 int crossPing, // The cross-ping.
352 void * param // User-data.
353);
354
355// This is called for watch keys when a room is joined, for
356// watch keys when another player joins, and for any newly
357// set watch keys.
359typedef void (* peerGlobalKeyChangedCallback)
360(
361 PEER peer, // The peer object.
362 const gsi_char * nick, // The player whose key changed.
363 const gsi_char * key, // The key.
364 const gsi_char * value, // The value.
365 void * param // User-data.
366);
367
368// This is called for watch keys when a room is joined, for
369// watch keys when another player joins, for any newly
370// set watch keys, and when a broadcast key is changed.
372typedef void (* peerRoomKeyChangedCallback)
373(
374 PEER peer, // The peer object.
375 RoomType roomType, // The room the player is in.
376 const gsi_char * nick, // The player whose key changed.
377 const gsi_char * key, // The key.
378 const gsi_char * value, // The value.
379 void * param // User-data.
380);
381
382// Called to report QR server keys.
383// Use qr2_buffer_add or qr2_buffer_add_int to
384// add this key's information to the buffer.
386typedef void (* peerQRServerKeyCallback)
387(
388 PEER peer, // The peer object.
389 int key, // The key for which to report information.
390 qr2_buffer_t buffer, // Fill in the information using this buffer.
391 void * param // User-data.
392);
393
394// Called to report QR player keys.
395// Use qr2_buffer_add or qr2_buffer_add_int to
396// add this key's information to the buffer.
398typedef void (* peerQRPlayerKeyCallback)
399(
400 PEER peer, // The peer object.
401 int key, // The key for which to report information.
402 int index, // The index of the player for which to report info.
403 qr2_buffer_t buffer, // Fill in the information using this buffer.
404 void * param // User-data.
405);
406
407// Called to report QR team keys.
408// Use qr2_buffer_add or qr2_buffer_add_int to
409// add this key's information to the buffer.
411typedef void (* peerQRTeamKeyCallback)
412(
413 PEER peer, // The peer object.
414 int key, // The key for which to report information.
415 int index, // The index of the team for which to report info.
416 qr2_buffer_t buffer, // Fill in the information using this buffer.
417 void * param // User-data.
418);
419
420// Called to get a list of keys to be reported.
421// Use qr2_keybuffer_add() to add keys.
422// The following keys do not need to be added, as peer already adds them:
423// GAMENAME_KEY, HOSTNAME_KEY, NUMPLAYERS_KEY, MAXPLAYERS_KEY,
424// GAMEMODE_KEY, PASSWORD_KEY, GROUPID_KEY, PLAYER__KEY, PING__KEY.
426typedef void (* peerQRKeyListCallback)
427(
428 PEER peer, // The peer object.
429 qr2_key_type type, // The type of keys being asked for (key_server, key_player, or key_team).
430 qr2_keybuffer_t keyBuffer, // Fill in the keys using this buffer.
431 void * param // User-data.
432);
433
434// Called to get a count of the number of players or teams.
436typedef int (* peerQRCountCallback)
437(
438 PEER peer, // The peer object.
439 qr2_key_type type, // The type of count to return (key_player or key_team).
440 void * param // User-data.
441);
442
443// Called when there is an error reporting the server.
445typedef void (* peerQRAddErrorCallback)
446(
447 PEER peer, // The peer object.
448 qr2_error_t error, // The type of error.
449 gsi_char * errorString, // A text string containing the error.
450 void * param // User-data.
451);
452
453// Called when hosting a server and a nat-negotiate cookie is received.
455typedef void (* peerQRNatNegotiateCallback)
456(
457 PEER peer, // The peer object.
458 int cookie, // A cookie sent from a potential client.
459 void * param // User-data.
460);
461
462// Called when hosting a server with the server's public reporting address.
464typedef void (* peerQRPublicAddressCallback)
465(
466 PEER peer, // The peer object.
467 unsigned int ip, // The public reporting IP
468 unsigned short port, // The public reporting port
469 void * param // User-data.
470);
471
472// This struct gets passed into peerInitialize().
473// param will be passed as the last parameter to each of the callbacks.
475typedef struct PEERCallbacks
476{
477 peerDisconnectedCallback disconnected;
478 peerRoomMessageCallback roomMessage;
479 peerRoomUTMCallback roomUTM;
480 peerRoomNameChangedCallback roomNameChanged; // PANTS|09.11.00
481 peerRoomModeChangedCallback roomModeChanged; // PANTS|04.17.01
482 peerPlayerMessageCallback playerMessage;
483 peerPlayerUTMCallback playerUTM;
484 peerReadyChangedCallback readyChanged;
485 peerGameStartedCallback gameStarted;
486 peerPlayerJoinedCallback playerJoined;
487 peerPlayerLeftCallback playerLeft;
488 peerKickedCallback kicked;
489 peerNewPlayerListCallback newPlayerList;
490 peerPlayerChangedNickCallback playerChangedNick;
491 peerPlayerInfoCallback playerInfo; // PANTS|01.08.01
492 peerPlayerFlagsChangedCallback playerFlagsChanged; // PANTS|03.12.01
493 peerPingCallback ping;
494 peerCrossPingCallback crossPing;
495 peerGlobalKeyChangedCallback globalKeyChanged;
496 peerRoomKeyChangedCallback roomKeyChanged;
497 peerQRServerKeyCallback qrServerKey;
498 peerQRPlayerKeyCallback qrPlayerKey;
499 peerQRTeamKeyCallback qrTeamKey;
500 peerQRKeyListCallback qrKeyList;
501 peerQRCountCallback qrCount;
502 peerQRAddErrorCallback qrAddError;
503 peerQRNatNegotiateCallback qrNatNegotiateCallback;
504 peerQRPublicAddressCallback qrPublicAddressCallback;
505 void * param;
507
508/************
509** UNICODE **
510************/
511#ifndef GSI_UNICODE
512#define peerConnect peerConnectA
513#define peerConnectLogin peerConnectLoginA
514#define peerConnectPreAuth peerConnectPreAuthA
515#define peerRetryWithNick peerRetryWithNickA
516#define peerRegisterUniqueNick peerRegisterUniqueNickA
517#define peerSetTitle peerSetTitleA
518#define peerGetTitle peerGetTitleA
519#define peerGetNick peerGetNickA
520#define peerFixNick peerFixNickA
521#define peerTranslateNick peerTranslateNickA
522#define peerChangeNick peerChangeNickA
523#define peerSetAwayMode peerSetAwayModeA
524#define peerParseQuery peerParseQueryA
525#define peerAuthenticateCDKey peerAuthenticateCDKeyA
526#define peerJoinTitleRoom peerJoinTitleRoomA
527#define peerJoinStagingRoom peerJoinStagingRoomA
528#define peerJoinStagingRoomByChannel peerJoinStagingRoomByChannelA
529#define peerCreateStagingRoom peerCreateStagingRoomA
530#define peerCreateStagingRoomWithSocket peerCreateStagingRoomWithSocketA
531#define peerLeaveRoom peerLeaveRoomA
532#define peerListGroupRooms peerListGroupRoomsA
533#define peerStartListingGames peerStartListingGamesA
534#define peerMessageRoom peerMessageRoomA
535#define peerUTMRoom peerUTMRoomA
536#define peerSetPassword peerSetPasswordA
537#define peerSetRoomName peerSetRoomNameA
538#define peerGetRoomName peerGetRoomNameA
539#define peerGetRoomChannel peerGetRoomChannelA
540#define peerSetTitleRoomChannel peerSetTitleRoomChannelA
541#define peerMessagePlayer peerMessagePlayerA
542#define peerUTMPlayer peerUTMPlayerA
543#define peerKickPlayer peerKickPlayerA
544#define peerGetPlayerPing peerGetPlayerPingA
545#define peerGetPlayersCrossPing peerGetPlayersCrossPingA
546#define peerPingPlayer peerPingPlayerA
547#define peerGetPlayerInfoNoWait peerGetPlayerInfoNoWaitA
548#define peerGetPlayerInfo peerGetPlayerInfoA
549#define peerGetPlayerProfileID peerGetPlayerProfileIDA
550#define peerGetPlayerIP peerGetPlayerIPA
551#define peerIsPlayerHost peerIsPlayerHostA
552#define peerGetPlayerFlags peerGetPlayerFlagsA
553#define peerGetReady peerGetReadyA
554#define peerStartGame peerStartGameA
555#define peerSetGlobalKeys peerSetGlobalKeysA
556#define peerGetPlayerGlobalKeys peerGetPlayerGlobalKeysA
557#define peerGetRoomGlobalKeys peerGetRoomGlobalKeysA
558#define peerSetRoomKeys peerSetRoomKeysA
559#define peerGetRoomKeys peerGetRoomKeysA
560#define peerSetGlobalWatchKeys peerSetGlobalWatchKeysA
561#define peerSetRoomWatchKeys peerSetRoomWatchKeysA
562#define peerGetGlobalWatchKey peerGetGlobalWatchKeyA
563#define peerGetRoomWatchKey peerGetRoomWatchKeyA
564#define peerStartAutoMatch peerStartAutoMatchA
565#define peerStartAutoMatchWithSocket peerStartAutoMatchWithSocketA
566#else
567#define peerConnect peerConnectW
568#define peerConnectLogin peerConnectLoginW
569#define peerConnectPreAuth peerConnectPreAuthW
570#define peerRetryWithNick peerRetryWithNickW
571#define peerRegisterUniqueNick peerRegisterUniqueNickW
572#define peerSetTitle peerSetTitleW
573#define peerGetTitle peerGetTitleW
574#define peerGetNick peerGetNickW
575#define peerFixNick peerFixNickW
576#define peerTranslateNick peerTranslateNickW
577#define peerChangeNick peerChangeNickW
578#define peerSetAwayMode peerSetAwayModeW
579#define peerParseQuery peerParseQueryA
580#define peerAuthenticateCDKey peerAuthenticateCDKeyW
581#define peerJoinTitleRoom peerJoinTitleRoomW
582#define peerJoinStagingRoom peerJoinStagingRoomW
583#define peerJoinStagingRoomByChannel peerJoinStagingRoomByChannelW
584#define peerCreateStagingRoom peerCreateStagingRoomW
585#define peerCreateStagingRoomWithSocket peerCreateStagingRoomWithSocketW
586#define peerLeaveRoom peerLeaveRoomW
587#define peerListGroupRooms peerListGroupRoomsW
588#define peerStartListingGames peerStartListingGamesW
589#define peerMessageRoom peerMessageRoomW
590#define peerUTMRoom peerUTMRoomW
591#define peerSetPassword peerSetPasswordW
592#define peerSetRoomName peerSetRoomNameW
593#define peerGetRoomName peerGetRoomNameW
594#define peerGetRoomChannel peerGetRoomChannelW
595#define peerSetTitleRoomChannel peerSetTitleRoomChannelW
596#define peerMessagePlayer peerMessagePlayerW
597#define peerUTMPlayer peerUTMPlayerW
598#define peerKickPlayer peerKickPlayerW
599#define peerGetPlayerPing peerGetPlayerPingW
600#define peerGetPlayersCrossPing peerGetPlayersCrossPingW
601#define peerPingPlayer peerPingPlayerW
602#define peerGetPlayerInfoNoWait peerGetPlayerInfoNoWaitW
603#define peerGetPlayerInfo peerGetPlayerInfoW
604#define peerGetPlayerProfileID peerGetPlayerProfileIDW
605#define peerGetPlayerIP peerGetPlayerIPW
606#define peerIsPlayerHost peerIsPlayerHostW
607#define peerGetPlayerFlags peerGetPlayerFlagsW
608#define peerGetReady peerGetReadyW
609#define peerStartGame peerStartGameW
610#define peerSetGlobalKeys peerSetGlobalKeysW
611#define peerGetPlayerGlobalKeys peerGetPlayerGlobalKeysW
612#define peerGetRoomGlobalKeys peerGetRoomGlobalKeysW
613#define peerSetRoomKeys peerSetRoomKeysW
614#define peerGetRoomKeys peerGetRoomKeysW
615#define peerSetGlobalWatchKeys peerSetGlobalWatchKeysW
616#define peerSetRoomWatchKeys peerSetRoomWatchKeysW
617#define peerGetGlobalWatchKey peerGetGlobalWatchKeyW
618#define peerGetRoomWatchKey peerGetRoomWatchKeyW
619#define peerStartAutoMatch peerStartAutoMatchW
620#define peerStartAutoMatchWithSocket peerStartAutoMatchWithSocketW
621#endif
622
623/************
624** GENERAL **
625************/
626// This creates and intializes a peer object.
627// NULL is returned in case of an error, otherwise a peer
628// object is returned.
629// If a peer object is returned, peerShutdown() must be called
630// to cleanup the object
632PEER peerInitialize
633(
634 PEERCallbacks * callbacks // Global callbacks.
635);
636
637// This gets called when the connection attempt finishes.
639typedef void (* peerConnectCallback)
640(
641 PEER peer, // The peer object.
642 PEERBool success, // PEERTrue if success, PEERFalse if failure.
643 int failureReason, // If failure, the reason for it (PEER_DISCONNECTED, etc.)
644 void * param // User-data.
645);
646
647// This gets called if there is an error with
648// the nickname while connecting.
649// Call peerRetryWithNick() to try another nick. If it
650// is called with a NULL nick, then the connect will be
651// stopped, and peerConnectCallback will be called with
652// failure.
653// The suggested nicks are only provided if type
654// is PEER_INVALID_UNIQUENICK.
656typedef void (* peerNickErrorCallback)
657(
658 PEER peer, // The peer object.
659 int type, // The type of nick error (PEER_IN_USE, PEER_INVALID, etc.)
660 const gsi_char * nick, // The bad nick.
661 int numSuggestedNicks, // The number of suggested nicks.
662 const gsi_char ** suggestedNicks, // The array of nicks.
663 void * param // User-data.
664);
665
666// This connects a peer object to a chat server.
667// Call peerDisconnect() to close the connection.
668// A title must be set with peerSetTitle before connecting.
670void peerConnect
671(
672 PEER peer, // The peer object.
673 const gsi_char * nick, // The nick to connect with.
674 int profileID, // The profileID, or 0 if no profileID.
675 peerNickErrorCallback nickErrorCallback, // Called if nick error.
676 peerConnectCallback connectCallback, // Called on complete.
677 void * param, // User-data.
678 PEERBool blocking // If PEERTrue, don't return until finished.
679);
680
681// Same as peerConnect, but also authenticates using a uniquenick
682// and password or an email, profilenick, and password.
684void peerConnectLogin
685(
686 PEER peer, // The peer object.
687 int namespaceID, // The namespace in which to login.
688 const gsi_char * email, // The email to login with.
689 const gsi_char * profilenick, // The profile to login with.
690 const gsi_char * uniquenick, // The uniquenick to login with.
691 const gsi_char * password, // The password for the login account.
692 peerNickErrorCallback nickErrorCallback, // Called if nick error.
693 peerConnectCallback connectCallback, // Called on complete.
694 void * param, // User-data.
695 PEERBool blocking // If PEERTrue, don't return until finished.
696);
697
698// Same as peerConnect, but also authenticates using an authtoken
699// and partnerchallenge from a partner account system.
701void peerConnectPreAuth
702(
703 PEER peer, // The peer object.
704 const gsi_char * authtoken, // The authtoken for this login.
705 const gsi_char * partnerchallenge, // The partner challenge for this login.
706 peerNickErrorCallback nickErrorCallback, // Called if nick error.
707 peerConnectCallback connectCallback, // Called on complete.
708 void * param, // User-data.
709 PEERBool blocking // If PEERTrue, don't return until finished.
710);
711
712// If peerNickErrorCallback is called, call this to
713// try and continue the connection with a new nickname.
714// If there is an error with this nick, the
715// peerNickErrCallback will be called again.
717void peerRetryWithNick
718(
719 PEER peer,
720 const gsi_char * nick
721);
722
723// Register a uniquenick.
724// Should be called in response to the peerNickErrorCallback being called
725// with a type of PEER_UNIQUENICK_EXPIRED or PEER_NO_UNIQUENICK.
726// If the uniquenick cannot be registered, the peerNickErrorCallback will
727// be called again with a type of PEER_IN_USE or PEER_INVALID.
729void peerRegisterUniqueNick
730(
731 PEER peer,
732 int namespaceID,
733 const gsi_char * uniquenick,
734 const gsi_char * cdkey
735);
736
737// Returns true if peer is connected.
738// PANTS|09.11.00
740PEERBool peerIsConnected(PEER peer);
741
742// Sets the current title.
743// A title must be set before connecting.
744// Returns PEERFalse if an error, or PEERTrue if success.
745// For most games the title/qrSecretKey and
746// sbName/sbSecretKey pairs will be the same.
748PEERBool peerSetTitle
749(
750 PEER peer, // The peer object.
751 const gsi_char * title, // The title to make current (ie., ut, gmtest).
752 const gsi_char * qrSecretKey, // The queryreporting secret key.
753 const gsi_char * sbName, // The serverbrowsing name.
754 const gsi_char * sbSecretKey, // The serverbrowsing secret key.
755 int sbGameVersion, // The version of the game doing the browsing.
756 int sbMaxUpdates, // The maximum number of concurent updates (10-15 for modem users, 20-30 for high-bandwidth).
757 PEERBool natNegotiate, // PEERTrue if the title supports GameSpy's NAT-negotiation technology (or another similar technology).
758 PEERBool pingRooms[NumRooms], // To do pings int a room, set it to PEERTrue.
759 PEERBool crossPingRooms[NumRooms] // To do cross-pings in a room, set it to PEERTrue.
760);
761
762// Resets peer to no title.
764void peerClearTitle(PEER peer);
765
766// Gets the currently set title.
767// Returns NULL if no title is set.
769const gsi_char * peerGetTitle(PEER peer);
770
771// Disconnect peer from the chat server.
773void peerDisconnect(PEER peer);
774
775// Shutdown peer.
776// The peer object should not be used again after this call.
778void peerShutdown(PEER peer);
779
780// Let's peer think.
781// This should be called at least every ~10ms,
782// typically, within the program's main loop.
784void peerThink(PEER peer);
785
786// Get the chat object associated with this peer object.
787// This returns NULL if peer isn't connected.
789CHAT peerGetChat(PEER peer);
790
791// Get the local user's nickname.
793const gsi_char * peerGetNick(PEER peer);
794
795// Replaces any invalid characters in nick with underscores.
797void peerFixNick
798(
799 gsi_char * newNick,
800 const gsi_char * oldNick
801);
802
803// Removes the namespace extension from a chat unique nick.
804// Returns the nick if it ended with the extension.
805// Otherwise returns NULL.
807const gsi_char * peerTranslateNick
808(
809 gsi_char * nick, // The nick to translate
810 const gsi_char * extension // The extension to be removed.
811);
812
813// Gets the local IP address. If called before
814// the peer object is connected, will return 0.
815// DEPRECATED - Use peerGetPublicIP.
817#define peerGetLocalIP peerGetPublicIP
818
819// Gets the local public IP address. If called before
820// the peer object is connected, will return 0.
822unsigned int peerGetPublicIP(PEER peer);
823
824// Gets the local private IP address.
826unsigned int peerGetPrivateIP(PEER peer);
827
828// Gets the local userID.
829// Only valid if connected with peerConnectLogin or peerConnectPreAuth.
831int peerGetUserID(PEER peer);
832
833// Gets the local profileID.
834// Only valid if connected with peerConnectLogin or peerConnectPreAuth.
836int peerGetProfileID(PEER peer);
837
838// This gets called when an attempt to change nicks is finished.
840typedef void (* peerChangeNickCallback)
841(
842 PEER peer, // The peer object.
843 PEERBool success, // PEERTrue if success, PEERFalse if failure.
844 const gsi_char * oldNick, // The old nickname.
845 const gsi_char * newNick, // The new nickname.
846 void * param // User-data.
847);
848
849// Changes the user's nickname.
851void peerChangeNick
852(
853 PEER peer, // The peer object.
854 const gsi_char * newNick, // The nickname to which to change.
855 peerChangeNickCallback callback, // Called when finished.
856 void * param, // Passed to the callback.
857 PEERBool blocking // If PEERTrue, don't return until finished.
858);
859
860// Causes Peer to not automatically leave the
861// room the next time peerSetTitle or peerClearTitle
862// is called. No effect if a title isn't set. When
863// the next title is set, the flag is cleared.
864// Only TitleRoom is currently supported.
865// This function is normally not needed.
867void peerStayInRoom
868(
869 PEER peer, // The peer object.
870 RoomType roomType // Only TitleRoom is currently supproted.
871);
872
873// Turns quiet mode on/off.
875void peerSetQuietMode
876(
877 PEER peer, // The peer object.
878 PEERBool quiet // If PEERTrue, enable quiet mode.
879);
880
881// Sets the away mode.
882// If an empty string or NULL, away mode is off.
883// If a valid string, away mode is on.
885void peerSetAwayMode
886(
887 PEER peer, // The peer object.
888 const gsi_char * reason // The away reason. If NULL or "", not away.
889);
890
891// When using peerStartReportingWithSocket or peerCreateStagingRoomWithSocket,
892// any qureries received on the sockets need to be passed to the SDK. Pass
893// the data using this function.
895void peerParseQuery
896(
897 PEER peer, // The peer object.
898 char * query, // String of query data.
899 int len, // The length of the string, not including the NUL.
900 struct sockaddr * sender // The address the query was received from.
901);
902
903// This gets called when an attempt to authenticate a CD key is finished.
904// If the result is 1, the CD key was authenticated. Otherwise, the CD
905// key was not authenticated.
907typedef void (* peerAuthenticateCDKeyCallback)
908(
909 PEER peer, // The peer object.
910 int result, // 1 if authenticated, otherwise not authenticated.
911 const gsi_char * message, // A string representing the result.
912 void * param // User-data.
913);
914
915// Sends a CD Key to the chat server for authentication.
916// The callback gets called when the chat server responds.
917// This call is required by some games to enter chat rooms.
918// It must be called after connecting to the chat server, but
919// before entering a room.
921void peerAuthenticateCDKey
922(
923 PEER peer, // The peer object.
924 const gsi_char * cdkey, // The CD key to authenticate.
925 peerAuthenticateCDKeyCallback callback, // Called when finished.
926 void * param, // Passed to the callback.
927 PEERBool blocking // If PEERTrue, don't return until finished.
928);
929
930// Sends a nat-negotiate cookie to a server.
932void peerSendNatNegotiateCookie
933(
934 PEER peer, // The peer object.
935 unsigned int ip, // IP (network byte order) of the server to send the cookie to.
936 unsigned short port, // Port (host byte order) of the server to send the cookie to.
937 int cookie // The cookie to send.
938);
939
940// Sends a client message to a QR2 server.
942void peerSendMessageToServer
943(
944 PEER peer,
945 unsigned int ip,
946 unsigned short port,
947 const char * data,
948 int len
949);
950
951// If always is PEERTrue, then players' IP and profile ID will
952// always be requested when joining a room. This info is normally
953// only requested if pings are set in a room. Use this function
954// to always request the information.
956void peerAlwaysGetPlayerInfo
957(
958 PEER peer, // The peer object.
959 PEERBool always // If true, always get player info.
960);
961
962/**********
963** ROOMS **
964**********/
965// This gets called when an attempt to join or create a room has finished.
967typedef void (* peerJoinRoomCallback)
968(
969 PEER peer, // The peer object.
970 PEERBool success, // PEERTrue if success, PEERFalse if failure.
971 PEERJoinResult result, // The result of the attempt.
972 RoomType roomType, // The type of room joined/created.
973 void * param // User-data.
974);
975
976// Joins the currently selected title's title room.
978void peerJoinTitleRoom
979(
980 PEER peer, // The peer object.
981 const gsi_char password[PEER_PASSWORD_LEN], // An optional password, normally NULL.
982 peerJoinRoomCallback callback, // Called when finished.
983 void * param, // Passed to the callback.
984 PEERBool blocking // If PEERTrue, don't return until finished.
985);
986
987// Joins a group room.
988// The groupID comes from the peerListGroupRoomsCallback.
990void peerJoinGroupRoom
991(
992 PEER peer, // The peer object.
993 int groupID, // The ID for the group to join.
994 peerJoinRoomCallback callback, // Called when finished.
995 void * param, // Passed to the callback.
996 PEERBool blocking // If PEERTrue, don't return until finished.
997);
998
999// Sets the group ID.
1000// Used to get a list of games in a group room and/or report or create a game
1001// in a particular group, without actually being in that group room. This is
1002// not needed if already using peerJoinGroupRoom.
1003// Setting a group ID of 0 is equivalent to leaving the group room.
1005void peerSetGroupID
1006(
1007 PEER peer, // The peer object.
1008 int groupID // The group ID to set
1009);
1010
1011// Returns the current group ID.
1012// The group ID is set with either peerJoinGroupRoom or peerSetGroupID.
1014int peerGetGroupID
1015(
1016 PEER peer // The peer object.
1017);
1018
1019// Joins a staging room.
1020// server is one of the server objects passed to peerListingGamesCallback().
1021// This call will only work if staging==PEERTrue for the server.
1022// PANTS|09.11.00 - The password is only needed for passworded rooms.
1023// PANTS|03.15.01 - No longer requires you to be actively listing games.
1025void peerJoinStagingRoom
1026(
1027 PEER peer, // The peer object.
1028 SBServer server, // The server passed into peerlistingGamesCallback().
1029 const gsi_char password[PEER_PASSWORD_LEN], // The password of the room being joined. Can be NULL or "".
1030 peerJoinRoomCallback callback, // Called when finished.
1031 void * param, // Passed to the callback.
1032 PEERBool blocking // If PEERTrue, don't return until finished.
1033);
1034
1035// Joins a staging room by its channel name.
1036// Same as peerJoinStagingRoom, except it takes the staging room's
1037// channel name instead of an SBServer object. Also, when the
1038// peerGameStartedCallback is called, the server paramter passed to
1039// it will be NULL.
1041void peerJoinStagingRoomByChannel
1042(
1043 PEER peer, // The peer object.
1044 const gsi_char * channel, // The channel to join.
1045 const gsi_char password[PEER_PASSWORD_LEN], // The password of the room being joined. Can be NULL or "".
1046 peerJoinRoomCallback callback, // Called when finished.
1047 void * param, // Passed to the callback.
1048 PEERBool blocking // If PEERTrue, don't return until finished.
1049);
1050
1051// Creates a new staging room, with the local player hosting.
1052// PANTS|09.11.00 - If the password parameter is not NULL
1053// or "", this will create a passworded room. The same
1054// case-sensitive password needs to be passed into
1055// peerJoinStagingRoom() for other player's to join the room.
1056// PANTS|09.11.00 - The staging room will be reported as part
1057// of whatever group room the local player was in when the
1058// room was created. Leaving the group room will not affect
1059// what group the staging room is reported as part of.
1061void peerCreateStagingRoom
1062(
1063 PEER peer, // The peer object.
1064 const gsi_char * name, // The name of the room.
1065 int maxPlayers, // The max number of players allowed in the room.
1066 const gsi_char password[PEER_PASSWORD_LEN], // An optional password for the staging room
1067 peerJoinRoomCallback callback, // Called when finished.
1068 void * param, // Passed to the callback.
1069 PEERBool blocking // If PEERTrue, don't return until finished.
1070);
1071
1072// Same as peerCreateStagingRoom, but uses the provided socket for
1073// sending heartbeats and query replies. This allows the game
1074// to share a socket with the peer SDK, which can make hosting
1075// games behind a NAT proxy possible.
1077void peerCreateStagingRoomWithSocket
1078(
1079 PEER peer, // The peer object.
1080 const gsi_char * name, // The name of the room.
1081 int maxPlayers, // The max number of players allowed in the room.
1082 const gsi_char password[PEER_PASSWORD_LEN], // An optional password for the staging room
1083 SOCKET socket, // The socket to be used for reporting.
1084 unsigned short port, // The local port to which the socket is bound.
1085 peerJoinRoomCallback callback, // Called when finished.
1086 void * param, // Passed to the callback.
1087 PEERBool blocking // If PEERTrue, don't return until finished.
1088);
1089
1090// Leave a room.
1091// PANTS|09.11.00 - You can now leave a group room
1092// without being forcibly removed from a staging room.
1094void peerLeaveRoom
1095(
1096 PEER peer, // The peer object.
1097 RoomType roomType, // The room you want to leave (TitleRoom, GroupRoom, or StagingRoom).
1098 const gsi_char * reason // The reason the player is leaving (can be NULL). PANTS|03.13.01
1099);
1100
1101// Gets called once for each group room when listing group rooms.
1102// After this has been called for each group room, it will be
1103// called one more time with groupID==0 and name==NULL.
1105typedef void (* peerListGroupRoomsCallback)
1106(
1107 PEER peer, // The peer object.
1108 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1109 int groupID, // A unique ID for this group.
1110 SBServer server, // The server object for this group room.
1111 const gsi_char * name, // The group room's name.
1112 int numWaiting, // The number of players in the room.
1113 int maxWaiting, // The maximum number of players allowed in the room.
1114 int numGames, // The number of games either staging or running in the group.
1115 int numPlaying, // The total number of players in games in the group.
1116 void * param // User-data.
1117);
1118
1119// List all the groups rooms for the currently set title.
1120// The fields parameter allows you to request extra info
1121// on each group room.
1123void peerListGroupRooms
1124(
1125 PEER peer, // The peer object.
1126 const gsi_char * fields, // A backslash delimited list of fields.
1127 peerListGroupRoomsCallback callback, // Called for each group room.
1128 void * param, // Passed to the callback.
1129 PEERBool blocking // If PEERTrue, don't return until finished.
1130);
1131
1132// Called with info on games being listed.
1133// Used to maintain a list of running games and staging rooms.
1134// The server object is a unique way of identifying each game.
1135// It can also be used with the calls in the "SBServer Object Functions" section
1136// of sb_serverbrowsing.h to find out more info about the server.
1137// If staging==PEERTrue, the game hasn't started yet, it's still in the staging room
1138// use peerJoinStagingRoom() to join the staging room, or if staging==peerfalse
1139// use the server object to get the game's IP and port to join with.
1140// During the _intial_ listing of games, progress is the percentage (0-100) of the
1141// games that have been added. Once the initial listing is completed,
1142// progress will always be 100.
1143// PANTS|09.11.00 - The "password" key will be set to 1 for games that are
1144// passworded. This can be checked with ServerGetIntValue(server, "password", 0).
1146typedef void (* peerListingGamesCallback)
1147(
1148 PEER peer, // The peer object.
1149 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1150 const gsi_char * name, // The name of the game being listed.
1151 SBServer server, // The server object for this game.
1152 PEERBool staging, // If PEERTrue, this is a staging room and not a running game.
1153 int msg, // The type of message this is.
1154 // PEER_CLEAR:
1155 // Clear the list. This has the same effect as if this was called
1156 // with PEER_REMOVE for every server listed.
1157 // PEER_ADD:
1158 // This is a new server. Add it to the list.
1159 // PEER_UPDATE:
1160 // This server is already on the list, and its been updated.
1161 // PEER_REMOVE:
1162 // Remove this server from the list. The server object for this server
1163 // should not be used again after this callback returns.
1164 int progress, // The percent of servers that have been added.
1165 void * param // User-data.
1166);
1167
1168// Start listing the currently running games and staging rooms.
1169// This is used to maintain a list that can presented to the user,
1170// so they can pick a game (or staging room) to join.
1171// Games and staging rooms are filtered based on what group the local
1172// user is in. If the local user isn't in a group, then only games
1173// and staging rooms that aren't part of any group are listed.
1174// The fields determine which info to request from the server. These
1175// must be registered QR2 keys (see qr2regkeys.h). HOSTNAME_KEY and
1176// GAMEMODE_KEY are automatically requested by Peer, so do not need
1177// to included.
1179void peerStartListingGames
1180(
1181 PEER peer, // The peer object.
1182 const unsigned char * fields, // An array of registered QR2 keys to request from servers.
1183 int numFields, // The number of keys in the fields array.
1184 const gsi_char * filter, // A SQL-like rule filter.
1185 peerListingGamesCallback callback, // Called when finished.
1186 void * param // Passed to the callback.
1187);
1188
1189// Stop games from being listed. This does NOT clear the games list.
1190// So all games listed are still considered valid. They stay valid
1191// until either another call to peerStartListingGames or until the
1192// title is cleared (or a new one set).
1194void peerStopListingGames
1195(
1196 PEER peer // The peer object.
1197);
1198
1199// Queries the game server for the latest information.
1200// If fullUpdate is PEERTrue, all of the keys will be requested.
1201// If fullUpdate is PEERFalse, only the keys passed to
1202// peerStartListingGames as the fields parameter will be requested.
1204void peerUpdateGame
1205(
1206 PEER peer, // The peer object.
1207 SBServer server, // The server object for the game to update.
1208 PEERBool fullUpdate // If true, get all of the game's keys.
1209);
1210
1211// 08-26-2004 Added by Saad Nader
1212// Queries the game server for the latest information via the master
1213// server.
1214// If fullUpdate is PEERTrue, all of the keys will be requested.
1215// If fullUpdate is PEERFalse, only the keys passed to
1216// peerStartListingGames as the fields parameter will be requested.
1218void peerUpdateGameByMaster
1219(
1220 PEER peer, // The peer object.
1221 SBServer server, // The server object for the game to update.
1222 PEERBool fullUpdate // If true, get all of the game's keys.
1223);
1224
1225// Send a ping to the server
1226// ICMP echo reply will be sent as response. The firewall
1227// or NAT between server and internet does not have to accept
1228// ICMP echo requests.
1230void peerUpdateGamePing(PEER peer, SBServer server);
1231
1232// Send a message to a room.
1234void peerMessageRoom
1235(
1236 PEER peer, // The peer object.
1237 RoomType roomType, // The room to send the message to.
1238 const gsi_char * message, // The message.
1239 MessageType messageType // The type of message.
1240);
1241
1242// Send a UTM to a room.
1244void peerUTMRoom
1245(
1246 PEER peer, // The peer object.
1247 RoomType roomType, // The room to send the UTM to.
1248 const gsi_char * command, // The command.
1249 const gsi_char * parameters, // The UTM's parameters.
1250 PEERBool authenticate // If true, the server will authenticate this UTM (should normally be false).
1251);
1252
1253// Set a password in a room you're hosting.
1254// The only roomType currently supported is StagingRoom.
1255// This will only work if the player is hosting the room.
1256// If password is NULL or "", the password will be cleared.
1258void peerSetPassword
1259(
1260 PEER peer, // The peer object.
1261 RoomType roomType, // The room in which to set the password.
1262 const gsi_char password[PEER_PASSWORD_LEN] // The password to set.
1263);
1264
1265// Set the name of a room you're hosting.
1266// The only roomType currently supported is StagingRoom.
1267// PANTS|09.11.00
1269void peerSetRoomName
1270(
1271 PEER peer, // The peer object.
1272 RoomType roomType, // The room in which to set the name.
1273 const gsi_char * name // The new name
1274);
1275
1276// Get a room's name (the channel's title).
1277// Returns NULL if not in the room.
1279const gsi_char * peerGetRoomName
1280(
1281 PEER peer, // The peer object.
1282 RoomType roomType // The room to get the name for.
1283);
1284
1285// Get's the chat channel associated with the room.
1286// Returns NULL if not in the room.
1288const gsi_char * peerGetRoomChannel
1289(
1290 PEER peer, // The peer object.
1291 RoomType roomType // The room to get the channel for.
1292);
1293
1294// Returns PEERTrue if in the room.
1296PEERBool peerInRoom
1297(
1298 PEER peer, // The peer object.
1299 RoomType roomType // The room to check for.
1300);
1301
1302// Use this channel for the title room for the currently set title.
1303// This function is normally not needed.
1305void peerSetTitleRoomChannel
1306(
1307 PEER peer, // The peer object.
1308 const gsi_char * channel // The channel to use for the title room.
1309);
1310
1311// Use this to get the SBServer object for the staging room host.
1312// This will return NULL if the local player is not in a staging room,
1313// is the staging room host, or joined using peerJoinStagingRoomByChannel.
1315SBServer peerGetHostServer(PEER peer);
1316
1317// Update the maximum number of players for a staging room
1319void peerSetStagingRoomMaxPlayers
1320(
1321 PEER peer,
1322 int maxPlayers
1323);
1324
1325/************
1326** PLAYERS **
1327************/
1328// Called for each player in a room being enumerated, and once
1329// when finished, with index==-1 and nick==NULL.
1331typedef void (* peerEnumPlayersCallback)
1332(
1333 PEER peer, // The peer object.
1334 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1335 RoomType roomType, // The room whose players are being enumerated.
1336 int index, // The index of the player (0 to (N - 1)). -1 when finished.
1337 const gsi_char * nick, // The nick of the player.
1338 int flags, // This player's flags (see #define's above). PANTS|03.12.01
1339 void * param // User-data.
1340);
1341
1342// Enumerates through the players in a room.
1344void peerEnumPlayers
1345(
1346 PEER peer, // The peer object.
1347 RoomType roomType, // The room to enum the players in.
1348 peerEnumPlayersCallback callback, // Called when finished.
1349 void * param // Passed to callback.
1350);
1351
1352// Send a message to a player.
1354void peerMessagePlayer
1355(
1356 PEER peer, // The peer object.
1357 const gsi_char * nick, // The nick of the player to send the message to.
1358 const gsi_char * message, // The message to send.
1359 MessageType messageType // The type of message.
1360);
1361
1362// Send a UTM to a player.
1364void peerUTMPlayer
1365(
1366 PEER peer, // The peer object.
1367 const gsi_char * nick, // The nick of the player to send the UTM to.
1368 const gsi_char * command, // The command.
1369 const gsi_char * parameters, // The UTM's parameters.
1370 PEERBool authenticate // If true, the server will authenticate this UTM (should normally be false).
1371);
1372
1373// Kick a player from a room.
1374// Can only be called by a player with host privileges.
1376void peerKickPlayer
1377(
1378 PEER peer, // The peer object.
1379 RoomType roomType, // The room to kick the player from.
1380 const gsi_char * nick, // The nick of the player to kick.
1381 const gsi_char * reason // An optional reason for kicking the player
1382);
1383
1384// Gets a player's ping (between the local machine and the player's machine).
1385// Returns PEERFalse if we don't have or can't get the player's ping.
1387PEERBool peerGetPlayerPing
1388(
1389 PEER peer, // The peer object.
1390 const gsi_char * nick, // The player to get the ping for.
1391 int * ping // The player's ping is stored here, if we have it.
1392);
1393
1394// Gets the cross-ping between 2 players.
1395// Returns PEERFalse if we don't have or can't get the player's cross-ping.
1397PEERBool peerGetPlayersCrossPing
1398(
1399 PEER peer, // The peer object.
1400 const gsi_char * nick1, // The first player.
1401 const gsi_char * nick2, // The second player.
1402 int * crossPing // The cross-ping is stored here, if we have it.
1403);
1404
1405// Peer already automatically pings all players that are in ping rooms.
1406// This function does a one-time ping of a remote player in a non-ping room.
1407// However pings must be enabled in at least one room for this to work,
1408// otherwise Peer will not open the UDP ping socket.
1409// Also, peerAlwaysGetPlayerInfo() must be enabled so that Peer has IPs for
1410// players that are only in non-ping rooms.
1412PEERBool peerPingPlayer
1413(
1414 PEER peer, // The peer object.
1415 const gsi_char * nick // The player to ping.
1416);
1417
1418// Gets a player's info immediately.
1419// Returns PEERFalse if the info is no available.
1421PEERBool peerGetPlayerInfoNoWait
1422(
1423 PEER peer,
1424 const gsi_char * nick,
1425 unsigned int * IP,
1426 int * profileID
1427);
1428
1429// Called as a result of a call to peerGetPlayerInfo().
1431typedef void (* peerGetPlayerInfoCallback)
1432(
1433 PEER peer, // The peer object.
1434 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1435 const gsi_char * nick, // The player's nick.
1436 unsigned int IP, // The player's IP, in network byte order.
1437 int profileID, // The player's profile ID.
1438 void * param // User-data.
1439);
1440
1441// Called to get a player's IP and profile ID.
1443void peerGetPlayerInfo
1444(
1445 PEER peer, // The peer object.
1446 const gsi_char * nick, // The player's nick.
1447 peerGetPlayerInfoCallback callback, // Called when finished.
1448 void * param, // Passed to callback.
1449 PEERBool blocking // If PEERTrue, don't return until finished.
1450);
1451
1452// Called as a result of a call to peerGetPlayerProfileID().
1454typedef void (* peerGetPlayerProfileIDCallback)
1455(
1456 PEER peer, // The peer object.
1457 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1458 const gsi_char * nick, // The player's nick.
1459 int profileID, // The player's profile ID.
1460 void * param // User-data.
1461);
1462
1463// Called to get a player's profile ID.
1464// DEPRECATED - Use peerGetPlayerInfo.
1466void peerGetPlayerProfileID
1467(
1468 PEER peer, // The peer object.
1469 const gsi_char * nick, // The player's nick.
1470 peerGetPlayerProfileIDCallback callback, // Called when finished.
1471 void * param, // Passed to callback.
1472 PEERBool blocking // If PEERTrue, don't return until finished.
1473);
1474
1475// Called as a result of a call to peerGetPlayerIP().
1477typedef void (* peerGetPlayerIPCallback)
1478(
1479 PEER peer, // The peer object.
1480 PEERBool success, // PEERTrue if success, PEERFalse if failure.
1481 const gsi_char * nick, // The player's nick.
1482 unsigned int IP, // The player's IP, in network byte order. PANTS|09.11.00 - was unsigned long
1483 void * param // User-data.
1484);
1485
1486// Called to get a player's IP.
1487// DEPRECATED - Use peerGetPlayerInfo.
1489void peerGetPlayerIP
1490(
1491 PEER peer, // The peer object.
1492 const gsi_char * nick, // The player's nick.
1493 peerGetPlayerIPCallback callback, // Called when finished.
1494 void * param, // Passed to callback.
1495 PEERBool blocking // If PEERTrue, don't return until finished.
1496);
1497
1498// Checks if a player is a host (has ops).
1499// Returns PEERTrue if yes, PEERFalse if no.
1501PEERBool peerIsPlayerHost
1502(
1503 PEER peer, // The peer object.
1504 const gsi_char * nick, // The player's nick.
1505 RoomType roomType // The room to check in.
1506);
1507
1508// Gets a player's flags in a room. Returns PEERFalse if
1509// the local player or this player is not in the room.
1511PEERBool peerGetPlayerFlags
1512(
1513 PEER peer,
1514 const gsi_char * nick,
1515 RoomType roomType,
1516 int * flags
1517);
1518
1519/*********
1520** GAME **
1521*********/
1522/**************** Disabled *************************/
1523// Returns the qr2 record used to report
1524// Primarily used for CD Key integration to prevent
1525// game intrusion and and post staging hacks
1527//qr2_t peerGetReportingRecord(PEER peer);
1528
1529// Sets the local player's ready state.
1530// PEERTrue if ready, PEERFalse if not ready.
1532void peerSetReady
1533(
1534 PEER peer, // The peer object.
1535 PEERBool ready // Ready or not.
1536);
1537
1538// Gets a player's ready state.
1540PEERBool peerGetReady
1541(
1542 PEER peer, // The peer object.
1543 const gsi_char * nick, // The player's nick.
1544 PEERBool * ready // The player's ready state gets stored in here.
1545);
1546
1547// Checks if all the player's in the staging room are ready.
1549PEERBool peerAreAllReady
1550(
1551 PEER peer // The peer object.
1552);
1553
1554// Called only by a staging room host to start the game.
1555// All the other people in the staging room will have their
1556// peerGameStartedCallback() called.
1557// The message gets passed to everyone in the peerGameStartedCallback(), and
1558// can be used to pass information such as a special port or password.
1559// If (reportingOptions & PEER_STOP_REPORTING), Peer will stop game reporting,
1560// so the program is responsible for any server reporting.
1561// If !(reportingOptions & PEER_STOP_REPORTING), Peer will continue doing
1562// game reporting, and calling the program-supplied callbacks. If
1563// (reportingOptions & PEER_REPORT_INFO), all server keys will still be
1564// reported. If (reportingOptions & PEER_REPORT_PLAYERS), all player keys
1565// will still be reported.
1567void peerStartGame
1568(
1569 PEER peer, // The peer object.
1570 const gsi_char * message, // A message to send to everyone.
1571 int reportingOptions // Bitfield flags used to set reporting options.
1572);
1573
1574// Starts server reporting, without creating a staging room.
1575// Call peerStopGame() to stop reporting.
1577PEERBool peerStartReporting
1578(
1579 PEER peer // The peer object.
1580);
1581
1582// Same as peerStartReporting, but uses the provided socket for
1583// sending heartbeats and query replies. This allows the game
1584// to share a socket with the peer SDK, , which can make hosting
1585// games behind a NAT proxy possible.
1587PEERBool peerStartReportingWithSocket
1588(
1589 PEER peer, // The peer object.
1590 SOCKET socket, // The socket to be used for reporting.
1591 unsigned short port // The local port to which the socket is bound.
1592);
1593
1594// Mark the local player as playing.
1595// Use this if the player is in a game not
1596// started by peer, but he should be marked as playing.
1598void peerStartPlaying
1599(
1600 PEER peer // The peer object.
1601);
1602
1603// Check to see if the local player is playing.
1605PEERBool peerIsPlaying
1606(
1607 PEER peer // The peer object.
1608);
1609
1610// Needs to be called by the host when the game has stopped.
1612void peerStopGame
1613(
1614 PEER peer // The peer object.
1615);
1616
1617// Call this when hosting a staging room or a game to force peer
1618// to report the game again. An example of when to call this is
1619// when a player joins or leaves a game.
1620// PANTS|09.11.00
1622void peerStateChanged
1623(
1624 PEER peer // The peer object.
1625);
1626
1627/*********
1628** KEYS **
1629*********/
1630// Set global keys on the local player.
1632void peerSetGlobalKeys
1633(
1634 PEER peer, // The peer object.
1635 int num, // The number of keys to set.
1636 const gsi_char ** keys, // The keys to set.
1637 const gsi_char ** values // The values for the keys.
1638);
1639
1640// Called with a player's global keys.
1642typedef void (* peerGetGlobalKeysCallback)
1643(
1644 PEER peer, // The peer object.
1645 PEERBool success, // If PEERFalse, unable to get the keys.
1646 const gsi_char * nick, // The player the keys are for.
1647 int num, // The number of keys.
1648 const gsi_char ** keys, // The keys got.
1649 const gsi_char ** values, // The values for the keys.
1650 void * param // User-data.
1651);
1652
1653// Get a player's global keys.
1655void peerGetPlayerGlobalKeys
1656(
1657 PEER peer, // The peer object.
1658 const gsi_char * nick, // The player to get the keys for.
1659 int num, // The number of keys.
1660 const gsi_char ** keys, // The keys to get.
1661 peerGetGlobalKeysCallback callback, // Called with the keys.
1662 void * param, // Passed to callback.
1663 PEERBool blocking // If PEERTrue, don't return until finished.
1664);
1665
1666// Get the global keys for all players in a room we're in.
1668void peerGetRoomGlobalKeys
1669(
1670 PEER peer, // The peer object.
1671 RoomType roomType, // The room to get the keys in.
1672 int num, // The number of keys.
1673 const gsi_char ** keys, // The keys to get.
1674 peerGetGlobalKeysCallback callback, // Called with the keys.
1675 void * param, // Passed to callback.
1676 PEERBool blocking // If PEERTrue, don't return until finished.
1677);
1678
1679// Set the room keys for a player.
1680// Use NULL or "" to set keys on the room itself.
1682void peerSetRoomKeys
1683(
1684 PEER peer, // The peer object.
1685 RoomType roomType, // The room to set the keys in.
1686 const gsi_char * nick, // The player to set the keys on (NULL or "" for the room).
1687 int num, // The number of keys.
1688 const gsi_char ** keys, // The keys to set.
1689 const gsi_char ** values // The values to set.
1690);
1691
1692// Called with a player's room keys.
1694typedef void (* peerGetRoomKeysCallback)
1695(
1696 PEER peer, // The peer object.
1697 PEERBool success, // If PEERFalse, unable to get the keys.
1698 RoomType roomType, // The room the keys are in.
1699 const gsi_char * nick, // The player the keys are for, or NULL for the room.
1700 int num, // The number of keys.
1701 gsi_char ** keys, // The keys.
1702 gsi_char ** values, // The values for the keys.
1703 void * param // User-data.
1704);
1705
1706// Get the room keys for either a single player of an entire room.
1707// Use "*" for the player to get the keys for the entire room.
1708// Use NULL or "" for the player to get keys on the room itself.
1710void peerGetRoomKeys
1711(
1712 PEER peer, // The peer object.
1713 RoomType roomType, // The room to get the keys in.
1714 const gsi_char * nick, // The player to get the keys for.
1715 int num, // The number of keys.
1716 const gsi_char ** keys, // The keys to get.
1717 peerGetRoomKeysCallback callback, // Called with the keys.
1718 void * param, // Passed to callback.
1719 PEERBool blocking // If PEERTrue, don't return until finished.
1720);
1721
1722// Set the global watch keys for a room type.
1723// If addKeys is set to PEERTrue, the keys will be
1724// added to the current global watch keys for this room.
1725// If addKeys is PEERFalse, these will replace any existing
1726// global watch keys for this room.
1727// When entering a room of the given type, peer will get and
1728// cache these keys for all players in the room.
1730void peerSetGlobalWatchKeys
1731(
1732 PEER peer, // The peer object.
1733 RoomType roomType, // The type of room to set the watch keys for.
1734 int num, // The number of keys.
1735 const gsi_char ** keys, // The keys to watch for.
1736 PEERBool addKeys // If PEERTrue, add these keys to the existing global watch keys for this room.
1737);
1738
1739// Set the room watch keys for a room type.
1740// If addKeys is set to PEERTrue, the keys will be
1741// added to the current room watch keys for this room.
1742// If addKeys is PEERFalse, these will replace any existing
1743// room watch keys for this room.
1744// When entering a room of the given type, peer will get and
1745// cache these keys for all players in the room.
1747void peerSetRoomWatchKeys
1748(
1749 PEER peer, // The peer object.
1750 RoomType roomType, // The type of room to set the watch keys for.
1751 int num, // The number of keys.
1752 const gsi_char ** keys, // The keys to watch for.
1753 PEERBool addKeys // If PEERTrue, add these keys to the existing room watch keys for this room.
1754);
1755
1756// Get the global watch key for a particular player.
1757// If the key isn't cached locally (either because it isn't
1758// a watch key or just isn't yet known), NULL will be returned.
1759// If the key is empty, "" will be returned.
1761const gsi_char * peerGetGlobalWatchKey
1762(
1763 PEER peer, // The peer object.
1764 const gsi_char * nick, // The player to get the key for.
1765 const gsi_char * key // The key to get.
1766);
1767
1768// Get the room watch key for a particular player in a room.
1769// If the key isn't cached locally (either because it isn't
1770// a watch key or just isn't yet known), NULL will be returned.
1771// If the key is empty, "" will be returned.
1773const gsi_char * peerGetRoomWatchKey
1774(
1775 PEER peer, // The peer object.
1776 RoomType roomType, // The room to get the key in.
1777 const gsi_char * nick, // The player to get the key for.
1778 const gsi_char * key // The key to get.
1779);
1780
1781/**************
1782** AUTOMATCH **
1783**************/
1784
1785// Called during a automatch attempt to inform the app of the status.
1787typedef void (* peerAutoMatchStatusCallback)
1788(
1789 PEER peer, // The peer object.
1790 PEERAutoMatchStatus status, // The current status.
1791 void * param // User-data.
1792);
1793
1794// This callback may be called during the automatch attempt.
1795// Peer uses the callback to ask the application how well a particular
1796// match fits what the user is looking for. The application checks the match
1797// and then returns a rating for it. If the rating is <=0 the match is
1798// considered unsuitable and Peer will not attempt that match. If the rating
1799// is >0 this match is considered suitable. The higher the rating, up to a
1800// maximum of INT_MAX, the more suitable the match. The exact scheme used
1801// to generate a rating is entirely up to the application. The match ratings
1802// are used by Peer both to check if a particular match meets the user's wishes
1803// and to compare matches to each other. Peer will first try to match with the
1804// highest rated possible match, then the second highest, etc.
1806typedef int (* peerAutoMatchRateCallback)
1807(
1808 PEER peer, // The peer object.
1809 SBServer match, // Possible match to rate.
1810 void * param // User-data.
1811);
1812
1813// Used to start a automatch attempt.
1814// The filter contains any hard criteria. This is used to narrow down the list
1815// of possible matches to those the user might consider.
1816// The status callback will be called as the attempt progresses, and the rate
1817// callback will be used to sort possible matches.
1819void peerStartAutoMatch
1820(
1821 PEER peer, // The peer object.
1822 int maxPlayers, // The total number of players to match (including the local player).
1823 const gsi_char * filter, // Hard criteria - filters out servers.
1824 peerAutoMatchStatusCallback statusCallback, // Called as the attempt status changes.
1825 peerAutoMatchRateCallback rateCallback, // Used to rate possible matches.
1826 void * param, // User-data.
1827 PEERBool blocking // If PEERTrue, don't return until finished.
1828);
1829
1830// Same as peerStartAutoMatch, but uses the provided socket for
1831// sending heartbeats and query replies. This allows the game
1832// to share a socket with the peer SDK, which can make hosting
1833// games behind a NAT proxy possible.
1835void peerStartAutoMatchWithSocket
1836(
1837 PEER peer, // The peer object.
1838 int maxPlayers, // The total number of players to match (including the local player).
1839 const gsi_char * filter, // Hard criteria - filters out servers.
1840 SOCKET socket, // The socket to be used for reporting.
1841 unsigned short port, // The local port to which the socket is bound.
1842 peerAutoMatchStatusCallback statusCallback, // Called as the attempt status changes.
1843 peerAutoMatchRateCallback rateCallback, // Used to rate possible matches.
1844 void * param, // User-data.
1845 PEERBool blocking // If PEERTrue, don't return until finished.
1846);
1847
1848// Stops an automatch attempt in progress.
1849// The user will not automatically be removed from any staging room he is in.
1851void peerStopAutoMatch(PEER peer);
1852
1853// Checks if a automatch attempt is in progress.
1855PEERBool peerIsAutoMatching(PEER peer);
1856
1857// Gets the current status of the automatch attempt.
1858// If no attempt is in progress, PEERFailed will be returned.
1860PEERAutoMatchStatus peerGetAutoMatchStatus(PEER peer);
1861
1862#ifdef __cplusplus
1863}
1864#endif
1865
1866#endif
Definition chat.h:81
Definition peer.h:476