1 /// \file
2 /// \brief Adds networking to AllGamesRoomsContainer. Lets you create, join, search, and destroy matchmaking rooms for players
3 ///
4 /// This file is part of RakNet Copyright 2003 Jenkins Software LLC
5 ///
6 /// Raknet is available under the terms of the GPLv3 license, see /usr/local/share/licenses/raknet-3.9.2_10,1/GPLv3.
7 
8 
9 #ifndef __ROOMS_PLUGIN_H
10 #define __ROOMS_PLUGIN_H
11 
12 class RakPeerInterface;
13 #include "RakNetTypes.h"
14 #include "PluginInterface2.h"
15 #include "DS_OrderedList.h"
16 #include "Export.h"
17 #include "ConnectionGraph.h"
18 #include "RoomsContainer.h"
19 #include "PacketPriority.h"
20 #include "BitStream.h"
21 
22 /// \defgroup ROOMS_GROUP RoomsPlugin
23 /// \brief Networked implementation of a rooms system, where members join and leave rooms.
24 /// \details
25 /// \ingroup PLUGINS_GROUP
26 
27 /// \defgroup ROOMS_COMMANDS RoomsCommands
28 /// \brief Commands that can be sent to RoomsPlugin
29 /// \details
30 /// \ingroup ROOMS_GROUP
31 
32 /// \defgroup ROOMS_NOTIFICATIONS RoomsNotifications
33 /// \brief Notifications that RoomsPlugin sends to you
34 /// \details
35 /// \ingroup ROOMS_GROUP
36 
37 namespace RakNet
38 {
39 
40 /// \brief Base class for rooms functionality
41 /// \details Operations performed on rooms are not in the RoomsPlugin - instead, each structure encapsulates one operation
42 /// \ingroup ROOMS_COMMANDS
43 struct RoomsPluginFunc {
RoomsPluginFuncRoomsPluginFunc44 	RoomsPluginFunc() {}
~RoomsPluginFuncRoomsPluginFunc45 	virtual ~RoomsPluginFunc() {}
46 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream)=0;
47 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream)=0;
48 	void PrintResult(void);
49 	/// \param[in] userName Who is performing this operation. Input parameter
50 	RakNet::RakString userName;
51 
52 	/// \param[out] resultCode Result of this operation
53 	RoomsErrorCode resultCode;
54 };
55 /// \brief Create a room. Each user can be in at most one room, so will fail if the user is already in a room
56 /// \ingroup ROOMS_COMMANDS
57 struct CreateRoom_Func : public RoomsPluginFunc {
58 	// Input parameters
59 	NetworkedRoomCreationParameters networkedRoomCreationParameters;
60 	GameIdentifier gameIdentifier;
61 	// If initialRoomProperties is not empty, then SetCustomRoomProperties_Func will be run after the room is created successfully
62 	DataStructures::Table initialRoomProperties;
63 
64 	// Output parameters
65 	RoomID roomId;
66 	RoomDescriptor roomDescriptor;
67 
68 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
69 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
70 };
71 /// \brief Joins a room if possible. If not, creates a room.
72 /// \ingroup ROOMS_COMMANDS
73 struct EnterRoom_Func : public RoomsPluginFunc {
74 
75 	// Input parameters
76 	NetworkedRoomCreationParameters networkedRoomCreationParameters;
77 	RoomMemberMode roomMemberMode;
78 	RoomQuery query;
79 	GameIdentifier gameIdentifier;
80 
81 	// Output parameters
82 	JoinedRoomResult joinedRoomResult;
83 	bool createdRoom;
84 	RoomID roomId;
85 
PrintResultEnterRoom_Func86 	void PrintResult(void)
87 	{
88 		if (resultCode!=REC_SUCCESS)
89 			printf("Result for user %s: %s\n", userName.C_String(), RoomsErrorCodeDescription::ToEnglish(resultCode));
90 		else if (createdRoom)
91 			printf("%s created a new room\n", userName.C_String());
92 		else
93 			printf("%s entered room with %i members\n", userName.C_String(), joinedRoomResult.roomDescriptor.roomMemberList.Size());
94 	}
95 
96 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
97 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
98 };
99 /// \brief Joins a room given the filter parameters and desired room member mode.
100 /// \details Room joins may fail if the room is locked, or does not have slots of the particular type
101 /// Room joins may succeed where they would otherwise fail if the user has an invitation to the room
102 /// \ingroup ROOMS_COMMANDS
103 struct JoinByFilter_Func : public RoomsPluginFunc {
104 	// Input parameters
105 	GameIdentifier gameIdentifier;
106 	RoomMemberMode roomMemberMode;
107 	RoomQuery query;
108 
109 	// Output parameters
110 	JoinedRoomResult joinedRoomResult;
111 
PrintResultJoinByFilter_Func112 	void PrintResult(void)
113 	{
114 		if (resultCode!=REC_SUCCESS)
115 			printf("Result for user %s: %s\n", userName.C_String(), RoomsErrorCodeDescription::ToEnglish(resultCode));
116 		else
117 		{
118 			printf("Joined room %s with id %i and %.0f used slots\n",
119 				joinedRoomResult.roomDescriptor.GetProperty(DefaultRoomColumns::TC_ROOM_NAME)->c, joinedRoomResult.roomDescriptor.lobbyRoomId,
120 				joinedRoomResult.roomDescriptor.GetProperty(DefaultRoomColumns::TC_USED_SLOTS)->i);
121 			for (unsigned int i=0; i < joinedRoomResult.roomDescriptor.roomMemberList.Size(); i++)
122 			{
123 				printf("%i. %s (%s)\n", i+1, joinedRoomResult.roomDescriptor.roomMemberList[i].name.C_String(), joinedRoomResult.roomDescriptor.roomMemberList[i].systemAddress.ToString());
124 			}
125 		}
126 	}
127 
128 
129 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
130 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
131 };
132 /// \brief Leaves a room. You can leave at any time, even if the room is locked.
133 /// \ingroup ROOMS_COMMANDS
134 struct LeaveRoom_Func : public RoomsPluginFunc {
135 	// Input parameters
136 	// Output parameters
137 	RemoveUserResult removeUserResult;
138 
139 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
140 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
141 };
142 /// Gets all invitations to you to various rooms.
143 /// \ingroup ROOMS_COMMANDS
144 struct GetInvitesToParticipant_Func : public RoomsPluginFunc {
145 	// Input parameters
146 	// Output parameters
147 	DataStructures::List<InvitedUser> invitedUsers;
148 
149 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
150 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
151 };
152 /// \brief Sends an invitation to someone.
153 /// \details Each user may have at most one invitation to the same room, although they have have invitations to multiple rooms.<BR>
154 /// This may fail depending on the room settings - the moderator may not allow other users to send invitations.<BR>
155 /// Invitations may be cleared when the moderator changes, depending on the room settings
156 /// \ingroup ROOMS_COMMANDS
157 struct SendInvite_Func : public RoomsPluginFunc {
158 	// Input parameters
159 	RakNet::RakString inviteeName;
160 	bool inviteToSpectatorSlot;
161 	RakNet::RakString subject;
162 	RakNet::RakString body;
163 	// Output parameters
164 
165 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
166 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
167 };
168 /// \brief Accept an invitation from a user to a room.
169 /// \details Invitations are the only way to join reserved slots. If all reserved slots are full, will join a public slot if possible.
170 /// \ingroup ROOMS_COMMANDS
171 struct AcceptInvite_Func : public RoomsPluginFunc {
172 	// Input parameters
173 	RakNet::RakString inviteSender;
174 	RoomID roomId;
175 	// Output parameters
176 
177 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
178 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
179 };
180 /// \brief Begin spectating. Spectators are considered room members that are not playing the game, only watching
181 /// \details Spectators do not count towards room ready states. The moderator can lock the room, preventing users from spectating, or not allow spectators at all
182 /// \ingroup ROOMS_COMMANDS
183 struct StartSpectating_Func : public RoomsPluginFunc {
184 	// Input parameters
185 	// Output parameters
186 
187 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
188 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
189 };
190 /// \brief Stop spectating. This will rejoin the room as a player, using a reserved slot if we were invited, and a public slot if not or if there are no reserved slots
191 /// \details This may fail if the moderator locked the room, or if no slots are available.
192 /// \ingroup ROOMS_COMMANDS
193 struct StopSpectating_Func : public RoomsPluginFunc {
194 	// Input parameters
195 	// Output parameters
196 
197 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
198 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
199 };
200 /// \brief Give moderator to another player. Moderators cannot be spectators.
201 /// \ingroup ROOMS_COMMANDS
202 struct GrantModerator_Func : public RoomsPluginFunc {
203 	// Input parameters
204 	RakNet::RakString newModerator;
205 	// Output parameters
206 
207 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
208 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
209 };
210 /// \brief Change the allowed slot counts for the room. Setting fewer slot counts than the number of players does not kick out players, though it may prevent changing spectator status
211 /// \ingroup ROOMS_COMMANDS
212 struct ChangeSlotCounts_Func : public RoomsPluginFunc {
213 	// Input parameters
214 	Slots slots;
215 	// Output parameters
216 
217 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
218 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
219 };
220 /// \brief Sets a table of user-defined room properties
221 /// \details Fill out the table with the column name, type, and value.<BR>
222 /// These properties are read when searching for rooms, and can be used as query filters to only join rooms with specified properties<BR>
223 /// See RoomTypes.h for default room properties.
224 /// \ingroup ROOMS_COMMANDS
225 struct SetCustomRoomProperties_Func : public RoomsPluginFunc {
226 	// Input parameters
227 	DataStructures::Table table;
228 	// Output parameters
229 
230 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
231 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
232 };
233 /// \brief Given a named room, return the properties of that room, including member list
234 /// \ingroup ROOMS_COMMANDS
235 struct GetRoomProperties_Func : public RoomsPluginFunc {
236 	// Input parameters
237 	// If blank, uses the room the user is currently in.
238 	RakNet::RakString roomName;
239 	// Output parameters
240 	RoomDescriptor roomDescriptor;
241 
PrintResultGetRoomProperties_Func242 	void PrintResult(void)
243 	{
244 
245 		if (resultCode!=REC_SUCCESS)
246 		{
247 			printf("Result for user %s: %s\n", userName.C_String(), RoomsErrorCodeDescription::ToEnglish(resultCode));
248 		}
249 		else
250 		{
251 //			char out[8096];
252 			printf("room %s has %i columns and %i used slots\n", roomName.C_String(),
253 				roomDescriptor.roomProperties.GetColumnCount(), roomDescriptor.roomMemberList.Size());
254 			RakAssert(roomDescriptor.GetProperty(DefaultRoomColumns::TC_USED_SLOTS)->i==roomDescriptor.roomMemberList.Size()-1);
255 	//		roomDescriptor.roomProperties.PrintColumnHeaders(out,8096,',');
256 	//		printf(out);
257 	//		roomDescriptor.roomProperties.PrintRow(out,8096,',',false,roomDescriptor.roomProperties.GetRowByIndex(0,0));
258 	//		printf(out);
259 		}
260 	}
261 
262 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
263 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
264 };
265 
266 /// \brief Change the name of the room
267 /// \ingroup ROOMS_COMMANDS
268 struct ChangeRoomName_Func : public RoomsPluginFunc {
269 	// Input parameters
270 	RakNet::RakString newRoomName;
271 	// Output parameters
272 
273 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
274 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
275 };
276 /// \brief Set or unset the room hidden from searches. If a room is hidden from searches, it can only be joined through invitations
277 /// \ingroup ROOMS_COMMANDS
278 struct SetHiddenFromSearches_Func : public RoomsPluginFunc {
279 	// Input parameters
280 	bool hiddenFromSearches;
281 	// Output parameters
282 
283 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
284 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
285 };
286 /// \brief Sets or unsets to destroy the room when the moderator leaves the room
287 /// \details If false, the next moderator will be the oldest member that is not a spectator.
288 /// \ingroup ROOMS_COMMANDS
289 struct SetDestroyOnModeratorLeave_Func : public RoomsPluginFunc {
290 	// Input parameters
291 	bool destroyOnModeratorLeave;
292 	// Output parameters
293 
294 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
295 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
296 };
297 /// \brief Sets or unsets the user as flagged 'ready'
298 /// \details Ready means ready to play the game. This flag can be set or unset by each room member.BR>
299 /// When all players are ready, the can will presumably start (although you can use this flag however you want).
300 /// \ingroup ROOMS_COMMANDS
301 struct SetReadyStatus_Func : public RoomsPluginFunc {
302 	// Input parameters
303 	bool isReady;
304 	// Output parameters
305 	DataStructures::List<RakNet::RakString> readyUsers;
306 	DataStructures::List<RakNet::RakString> unreadyUsers;
307 
PrintResultSetReadyStatus_Func308 	void PrintResult(void)
309 	{
310 		if (resultCode!=REC_SUCCESS)
311 		{
312 			printf("Result for user %s: %s\n", userName.C_String(), RoomsErrorCodeDescription::ToEnglish(resultCode));
313 		}
314 		else
315 		{
316 			printf("SetReadyStatus_Func member ready states:\n");
317 			if (readyUsers.Size()>0)
318 			{
319 				printf("Ready: ");
320 				for (unsigned int i=0; i < readyUsers.Size(); i++)
321 				{
322 					printf("%s ", readyUsers[i].C_String());
323 				}
324 
325 				printf("\n");
326 			}
327 
328 			if (unreadyUsers.Size()>0)
329 			{
330 				printf("Unready: ");
331 				for (unsigned int i=0; i < unreadyUsers.Size(); i++)
332 				{
333 					printf("%s ", unreadyUsers[i].C_String());
334 				}
335 
336 				printf("\n");
337 			}
338 
339 		}
340 	}
341 
342 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
343 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
344 };
345 /// \brief Gets the ready states for every user in the room, excluding spectators
346 /// \ingroup ROOMS_COMMANDS
347 struct GetReadyStatus_Func : public RoomsPluginFunc {
348 	// Input parameters
349 	// Output parameters
350 	DataStructures::List<RakNet::RakString> readyUsers;
351 	DataStructures::List<RakNet::RakString> unreadyUsers;
352 
353 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
354 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
355 };
356 /// \brief Lock or unlock the room
357 /// \details If the room is locked, no further players can join regardless of the available room slots. This includes invited players.<BR>
358 /// Rooms default to unlocked
359 /// \ingroup ROOMS_COMMANDS
360 struct SetRoomLockState_Func : public RoomsPluginFunc {
361 	// Input parameters
362 	RoomLockState roomLockState;
363 	// Output parameters
364 
365 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
366 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
367 };
368 /// \brief Gets the lock state of the room
369 /// \ingroup ROOMS_COMMANDS
370 struct GetRoomLockState_Func : public RoomsPluginFunc {
371 	// Input parameters
372 	// Output parameters
373 	RoomLockState roomLockState;
374 
375 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
376 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
377 };
378 /// \brief If all members have been set to ready using SetReadyStatus_Func, this operation will set allReady to true.
379 /// \ingroup ROOMS_COMMANDS
380 struct AreAllMembersReady_Func : public RoomsPluginFunc {
381 	// Input parameters
382 	// Output parameters
383 	bool allReady;
384 
385 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
386 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
387 };
388 /// \brief Kick a member out of the room. This will also automatically ban that member from rejoining as long as the moderator does not change, or the member is unbanned
389 /// \ingroup ROOMS_COMMANDS
390 struct KickMember_Func : public RoomsPluginFunc {
391 	// Input parameters
392 	RakNet::RakString kickedMember;
393 	RakNet::RakString reason;
394 	// Output parameters
395 
396 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
397 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
398 };
399 /// \brief Allow a member previously kicked out of the room to rejoin.
400 /// \ingroup ROOMS_COMMANDS
401 struct UnbanMember_Func : public RoomsPluginFunc {
402 	// Input parameters
403 	RakNet::RakString bannedMemberName;
404 	// Output parameters
405 
406 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
407 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
408 };
409 /// \brief For a given room, get the \a reason parameter of KickMember_Func when we were kicked out.
410 /// \ingroup ROOMS_COMMANDS
411 struct GetBanReason_Func : public RoomsPluginFunc {
412 	// Input parameters
413 	RoomID roomId;
414 	// Output parameters
415 	RakNet::RakString reason;
416 
417 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
418 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
419 };
420 /// \brief Enter quick join mode
421 /// \details Quick join mode will wait until the specified timeout to try to automatically join a room each second.<BR>
422 /// A room will only be joined if enough quick join members can join at once to fill all playable slots in the room.<BR>
423 /// Older rooms are given priority to quick join.<BR>
424 /// If no rooms are available to join, but enough quick join members are present to create a room instead, this will be done. The room custom properties will be any equality comparisons with networkedQuickJoinUser.query
425 /// \ingroup ROOMS_COMMANDS
426 struct AddUserToQuickJoin_Func : public RoomsPluginFunc {
427 	// Input parameters
428 	NetworkedQuickJoinUser networkedQuickJoinUser;
429 	GameIdentifier gameIdentifier;
430 	// Output parameters
431 
432 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
433 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
434 };
435 /// \brief Leave quick join mode
436 /// \ingroup ROOMS_COMMANDS
437 struct RemoveUserFromQuickJoin_Func : public RoomsPluginFunc {
438 	// Input parameters
439 	// Output parameters
440 
441 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
442 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
443 };
444 /// \brief Returns if you are waiting in quick join mode
445 /// \ingroup ROOMS_COMMANDS
446 struct IsInQuickJoin_Func : public RoomsPluginFunc {
447 	// Input parameters
448 	// Output parameters
449 	bool isInQuickJoin;
450 
451 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
452 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
453 };
454 /// \brief Return all rooms that pass the \a roomQuery filter
455 /// \details Use onlyJoinable to further filter by rooms that you can join (not locked, not banned, public or invited slots)
456 /// \ingroup ROOMS_COMMANDS
457 struct SearchByFilter_Func : public RoomsPluginFunc {
SearchByFilter_FuncSearchByFilter_Func458 	SearchByFilter_Func() {}
459 	~SearchByFilter_Func();
460 	// Input parameters
461 	GameIdentifier gameIdentifier;
462 	RoomQuery roomQuery;
463 	bool onlyJoinable;
464 	// Output parameters
465 	DataStructures::List<RoomDescriptor*> roomsOutput;
466 
PrintResultSearchByFilter_Func467 	void PrintResult(void)
468 	{
469 		if (resultCode!=REC_SUCCESS)
470 		{
471 			printf("Result for user %s: %s\n", userName.C_String(), RoomsErrorCodeDescription::ToEnglish(resultCode));
472 		}
473 		else
474 		{
475 			printf("Found %i rooms\n", roomsOutput.Size());
476 			for (unsigned int i=0; i < roomsOutput.Size(); i++)
477 			{
478 				// Default types such as room name are in RoomTypes.cpp see defaultRoomColumns
479 				// Also can be user defined
480 				printf("%i. %s\n", i+1,roomsOutput[i]->GetProperty(DefaultRoomColumns::TC_ROOM_NAME)->c);
481 			}
482 		}
483 	}
484 
485 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
486 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
487 };
488 /// \brief Change your handle
489 /// \ingroup ROOMS_COMMANDS
490 struct ChangeHandle_Func : public RoomsPluginFunc {
491 	// Input parameters
492 	RakNet::RakString newHandle;
493 	// Output parameters
494 
495 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
496 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
497 };
498 /// \brief Send a chat message
499 /// \ingroup ROOMS_COMMANDS
500 struct Chat_Func : public RoomsPluginFunc {
501 	// Input parameters
502 	RakNet::RakString chatMessage;
503 	// Leave recipient blank for all in room
504 	RakNet::RakString privateMessageRecipient;
505 	/// If true, only sends the chat message if the user is in the same room.
506 	/// If false, privateMessageRecipient must also be filled out
507 	bool chatDirectedToRoom;
508 
509 	// Output parameters
510 
511 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
512 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
513 };
514 /// \brief Send an arbitrary binary message
515 /// \ingroup ROOMS_COMMANDS
516 struct Bitstream_Func : public RoomsPluginFunc {
517 	// Input parameters
518 	RakNet::BitStream bsToSend;
519 	// Leave recipient blank for all in room
520 	RakNet::RakString privateMessageRecipient;
521 	/// If true, only sends the bitstream if the user is in the same room.
522 	/// If false, privateMessageRecipient must also be filled out
523 	bool directedToRoom;
524 
525 	// Output parameters
526 
527 	virtual void SerializeIn(bool writeToBitstream, RakNet::BitStream *bitStream);
528 	virtual void SerializeOut(bool writeToBitstream, RakNet::BitStream *bitStream);
529 };
530 /// \brief Base class for notification callbacks
531 /// \ingroup ROOMS_GROUP
532 struct RoomsPluginNotification {
~RoomsPluginNotificationRoomsPluginNotification533 	virtual ~RoomsPluginNotification() {}
534 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream)=0;
535 	virtual void PrintResult(void)=0;
536 	/// Always filled out so you know which user this callback applies to
537 	RakNet::RakString recipient;
538 };
539 /// \brief The quick join duration has expired without joining or creating any rooms
540 /// \ingroup ROOMS_NOTIFICATIONS
541 struct QuickJoinExpired_Notification : public RoomsPluginNotification {
542 	NetworkedQuickJoinUser networkedQuickJoinUser;
543 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultQuickJoinExpired_Notification544 	virtual void PrintResult(void) {printf("QuickJoinExpired_Notification to %s\n", recipient.C_String());}
545 };
546 /// \brief Quick join succeeded, and you are now in a room
547 /// \ingroup ROOMS_NOTIFICATIONS
548 struct QuickJoinEnteredRoom_Notification : public RoomsPluginNotification {
549 	JoinedRoomResult joinedRoomResult;
550 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultQuickJoinEnteredRoom_Notification551 	virtual void PrintResult(void) {printf("QuickJoinEnteredRoom_Notification to %s. roomId=%i\n", recipient.C_String(), joinedRoomResult.roomDescriptor.lobbyRoomId);}
552 };
553 /// \brief Another room member has started spectating
554 /// \ingroup ROOMS_NOTIFICATIONS
555 struct RoomMemberStartedSpectating_Notification : public RoomsPluginNotification {
556 	RoomID roomId;
557 	RakNet::RakString userName;
558 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberStartedSpectating_Notification559 	virtual void PrintResult(void) {printf("RoomMemberStartedSpectating_Notification to %s\n", recipient.C_String());}
560 };
561 /// \brief Another room member has stopped spectating
562 /// \ingroup ROOMS_NOTIFICATIONS
563 struct RoomMemberStoppedSpectating_Notification : public RoomsPluginNotification {
564 	RakNet::RakString userName;
565 	RoomID roomId;
566 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberStoppedSpectating_Notification567 	virtual void PrintResult(void) {printf("RoomMemberStoppedSpectating_Notification to %s\n", recipient.C_String());}
568 };
569 /// \brief The room has a new moderator (possibly you)
570 /// \ingroup ROOMS_NOTIFICATIONS
571 struct ModeratorChanged_Notification : public RoomsPluginNotification {
572 	RakNet::RakString newModerator;
573 	RakNet::RakString oldModerator;
574 	RoomID roomId;
PrintResultModeratorChanged_Notification575 	virtual void PrintResult(void) {printf("ModeratorChanged_Notification to %s\n", recipient.C_String());}
576 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
577 };
578 /// \brief The slot counts in the room has changed
579 /// \ingroup ROOMS_NOTIFICATIONS
580 struct SlotCountsSet_Notification : public RoomsPluginNotification {
581 	Slots slots;
582 	RoomID roomId;
583 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultSlotCountsSet_Notification584 	virtual void PrintResult(void) {printf("SlotCountsSet_Notification to %s\n", recipient.C_String());}
585 };
586 
587 /// \brief The custom properties for the room has changed
588 /// \ingroup ROOMS_NOTIFICATIONS
589 struct CustomRoomPropertiesSet_Notification : public RoomsPluginNotification {
590 	RoomID roomId;
591 	// If tablePtr is set, that will be serialized. Otherwise, table will be serialized.
592 	// Deserialization is written to table
593 	DataStructures::Table *tablePtr;
594 	DataStructures::Table table;
595 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultCustomRoomPropertiesSet_Notification596 	virtual void PrintResult(void) {printf("CustomRoomPropertiesSet_Notification to %s\n", recipient.C_String());}
597 };
598 /// \brief The name of the room has been changed
599 /// \ingroup ROOMS_NOTIFICATIONS
600 struct RoomNameSet_Notification : public RoomsPluginNotification {
601 	RoomID roomId;
602 	RakNet::RakString oldName;
603 	RakNet::RakString newName;
604 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomNameSet_Notification605 	virtual void PrintResult(void) {printf("RoomNameSet_Notification to %s\n", recipient.C_String());}
606 };
607 /// \brief The room is now hidden, or no longer hidden, from searches
608 /// \ingroup ROOMS_NOTIFICATIONS
609 struct HiddenFromSearchesSet_Notification : public RoomsPluginNotification {
610 	RoomID roomId;
611 	bool hiddenFromSearches;
612 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultHiddenFromSearchesSet_Notification613 	virtual void PrintResult(void) {printf("HiddenFromSearchesSet_Notification to %s\n", recipient.C_String());}
614 };
615 /// \brief Another room member has changed their ready status
616 /// \ingroup ROOMS_NOTIFICATIONS
617 struct RoomMemberReadyStatusSet_Notification : public RoomsPluginNotification {
618 	RoomID roomId;
619 	bool isReady;
620 	RakNet::RakString roomMember;
621 
622 	// Current status of all room members
623 	DataStructures::List<RakNet::RakString> readyUsers;
624 	DataStructures::List<RakNet::RakString> unreadyUsers;
625 
626 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberReadyStatusSet_Notification627 	virtual void PrintResult(void) {printf("RoomMemberReadyStatusSet_Notification to %s\n", recipient.C_String());}
628 };
629 /// \brief The room is now, or is no longer, locked
630 /// \ingroup ROOMS_NOTIFICATIONS
631 struct RoomLockStateSet_Notification : public RoomsPluginNotification {
632 	RoomID roomId;
633 	RoomLockState roomLockState;
634 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomLockStateSet_Notification635 	virtual void PrintResult(void) {printf("RoomLockStateSet_Notification to %s\n", recipient.C_String());}
636 };
637 /// \brief A room member has been kicked out of the room (possibly you)
638 /// \ingroup ROOMS_NOTIFICATIONS
639 struct RoomMemberKicked_Notification : public RoomsPluginNotification {
640 	RoomID roomId;
641 	RakNet::RakString kickedMember;
642 	RakNet::RakString moderator;
643 	RakNet::RakString reason;
644 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberKicked_Notification645 	virtual void PrintResult(void) {printf("RoomMemberKicked_Notification to %s\n", recipient.C_String());}
646 };
647 /// \brief A room member has changed their handle
648 /// \ingroup ROOMS_NOTIFICATIONS
649 struct RoomMemberHandleSet_Notification : public RoomsPluginNotification {
650 	RoomID roomId;
651 	RakNet::RakString oldName;
652 	RakNet::RakString newName;
653 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberHandleSet_Notification654 	virtual void PrintResult(void) {printf("RoomMemberHandleSet_Notification to %s\n", recipient.C_String());}
655 };
656 /// A room member has left the room
657 /// \ingroup ROOMS_NOTIFICATIONS
658 struct RoomMemberLeftRoom_Notification : public RoomsPluginNotification {
659 	RoomID roomId;
660 	RakNet::RakString roomMember;
661 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberLeftRoom_Notification662 	virtual void PrintResult(void) {printf("RoomMemberLeftRoom_Notification to %s\n", recipient.C_String());}
663 };
664 /// \brief A room member has joined the room
665 /// \ingroup ROOMS_NOTIFICATIONS
666 struct RoomMemberJoinedRoom_Notification : public RoomsPluginNotification {
RoomMemberJoinedRoom_NotificationRoomMemberJoinedRoom_Notification667 	RoomMemberJoinedRoom_Notification() {joinedRoomResult=0;}
~RoomMemberJoinedRoom_NotificationRoomMemberJoinedRoom_Notification668 	~RoomMemberJoinedRoom_Notification() {if (joinedRoomResult!=0) RakNet::OP_DELETE(joinedRoomResult, __FILE__, __LINE__);}
669 	RoomID roomId;
670 	JoinedRoomResult *joinedRoomResult;
671 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomMemberJoinedRoom_Notification672 	virtual void PrintResult(void)
673 	{
674 		printf("RoomMemberJoinedRoom_Notification to %s: %s (%s) has joined the room.\n", recipient.C_String(), joinedRoomResult->joiningMemberName.C_String(), joinedRoomResult->joiningMemberAddress.ToString());
675 	}
676 };
677 /// \brief You have received an invitation to a room
678 /// \ingroup ROOMS_NOTIFICATIONS
679 struct RoomInvitationSent_Notification : public RoomsPluginNotification {
680 	RakNet::RakString invitorName;
681 	RakNet::RakString inviteeName;
682 	bool inviteToSpectatorSlot;
683 	RakNet::RakString subject;
684 	RakNet::RakString body;
685 	RoomID roomId;
686 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomInvitationSent_Notification687 	virtual void PrintResult(void) {printf("RoomInvitationSent_Notification to %s\n", recipient.C_String());}
688 };
689 /// \brief A previous room invitation is no longer valid (possibly due to moderator change, or the room no longer exists)
690 /// \ingroup ROOMS_NOTIFICATIONS
691 struct RoomInvitationWithdrawn_Notification : public RoomsPluginNotification {
692 	InvitedUser invitedUser;
693 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomInvitationWithdrawn_Notification694 	virtual void PrintResult(void) {printf("RoomInvitationWithdrawn_Notification to %s\n", recipient.C_String());}
695 };
696 /// \brief The moderator has left the room, and everyone left is a spectator, or the room was set to be destroyed when the moderator left
697 /// \ingroup ROOMS_NOTIFICATIONS
698 /// You are no longer in the room
699 struct RoomDestroyedOnModeratorLeft_Notification : public RoomsPluginNotification {
700 	RakNet::RakString oldModerator;
701 	RoomID roomId;
702 	RoomDescriptor roomDescriptor;
703 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultRoomDestroyedOnModeratorLeft_Notification704 	virtual void PrintResult(void) {printf("RoomDestroyedOnModeratorLeft_Notification to %s\n", recipient.C_String());}
705 };
706 /// \brief You got a chat message from another user.
707 /// \details If you want to support ignoring chat messages from specific users, use Lobby2Client_PC::IsInIgnoreList
708 /// \ingroup ROOMS_NOTIFICATIONS
709 struct Chat_Notification : public RoomsPluginNotification {
710 	RakNet::RakString sender;
711 	// If filled in, this was directed to you. Otherwise it was directed to the room
712 	RakNet::RakString privateMessageRecipient;
713 	// The chat message
714 	RakNet::RakString chatMessage;
715 	// The chat message with profanity filtered, if you want that instead
716 	RakNet::RakString filteredChatMessage;
717 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultChat_Notification718 	virtual void PrintResult(void) {printf("Chat_Notification to %s\n", recipient.C_String());}
719 };
720 /// \brief You got a generic bitstream message from another user.
721 /// \ingroup ROOMS_NOTIFICATIONS
722 struct Bitstream_Notification : public RoomsPluginNotification {
723 	RakNet::RakString sender;
724 	// If filled in, this was directed to you. Otherwise it was directed to the room
725 	RakNet::RakString privateMessageRecipient;
726 	// The chat message
727 	RakNet::BitStream bitStreamReceived;
728 	virtual void Serialize(bool writeToBitstream, RakNet::BitStream *bitStream);
PrintResultBitstream_Notification729 	virtual void PrintResult(void) {printf("Bitstream_Notification to %s\n", recipient.C_String());}
730 };
731 /// \ingroup ROOMS_GROUP
732 struct RoomsCallback
733 {
734 	// Results of calls
RoomsCallbackRoomsCallback735 	RoomsCallback() {}
~RoomsCallbackRoomsCallback736 	virtual ~RoomsCallback() {}
CreateRoom_CallbackRoomsCallback737 	virtual void CreateRoom_Callback( SystemAddress senderAddress, CreateRoom_Func *callResult) {(void) senderAddress; (void) callResult;}
EnterRoom_CallbackRoomsCallback738 	virtual void EnterRoom_Callback( SystemAddress senderAddress, EnterRoom_Func *callResult) {(void) senderAddress; (void) callResult;}
JoinByFilter_CallbackRoomsCallback739 	virtual void JoinByFilter_Callback( SystemAddress senderAddress, JoinByFilter_Func *callResult) {(void) senderAddress; (void) callResult;}
LeaveRoom_CallbackRoomsCallback740 	virtual void LeaveRoom_Callback( SystemAddress senderAddress, LeaveRoom_Func *callResult) {(void) senderAddress; (void) callResult;}
GetInvitesToParticipant_CallbackRoomsCallback741 	virtual void GetInvitesToParticipant_Callback( SystemAddress senderAddress, GetInvitesToParticipant_Func *callResult) {(void) senderAddress; (void) callResult;}
SendInvite_CallbackRoomsCallback742 	virtual void SendInvite_Callback( SystemAddress senderAddress, SendInvite_Func *callResult) {(void) senderAddress; (void) callResult;}
AcceptInvite_CallbackRoomsCallback743 	virtual void AcceptInvite_Callback( SystemAddress senderAddress, AcceptInvite_Func *callResult) {(void) senderAddress; (void) callResult;}
StartSpectating_CallbackRoomsCallback744 	virtual void StartSpectating_Callback( SystemAddress senderAddress, StartSpectating_Func *callResult) {(void) senderAddress; (void) callResult;}
StopSpectating_CallbackRoomsCallback745 	virtual void StopSpectating_Callback( SystemAddress senderAddress, StopSpectating_Func *callResult) {(void) senderAddress; (void) callResult;}
GrantModerator_CallbackRoomsCallback746 	virtual void GrantModerator_Callback( SystemAddress senderAddress, GrantModerator_Func *callResult) {(void) senderAddress; (void) callResult;}
ChangeSlotCounts_CallbackRoomsCallback747 	virtual void ChangeSlotCounts_Callback( SystemAddress senderAddress, ChangeSlotCounts_Func *callResult) {(void) senderAddress; (void) callResult;}
SetCustomRoomProperties_CallbackRoomsCallback748 	virtual void SetCustomRoomProperties_Callback( SystemAddress senderAddress, SetCustomRoomProperties_Func *callResult) {(void) senderAddress; (void) callResult;}
GetRoomProperties_CallbackRoomsCallback749 	virtual void GetRoomProperties_Callback( SystemAddress senderAddress, GetRoomProperties_Func *callResult) {(void) senderAddress; (void) callResult;}
ChangeRoomName_CallbackRoomsCallback750 	virtual void ChangeRoomName_Callback( SystemAddress senderAddress, ChangeRoomName_Func *callResult) {(void) senderAddress; (void) callResult;}
SetHiddenFromSearches_CallbackRoomsCallback751 	virtual void SetHiddenFromSearches_Callback( SystemAddress senderAddress, SetHiddenFromSearches_Func *callResult) {(void) senderAddress; (void) callResult;}
SetDestroyOnModeratorLeave_CallbackRoomsCallback752 	virtual void SetDestroyOnModeratorLeave_Callback( SystemAddress senderAddress, SetDestroyOnModeratorLeave_Func *callResult) {(void) senderAddress; (void) callResult;}
SetReadyStatus_CallbackRoomsCallback753 	virtual void SetReadyStatus_Callback( SystemAddress senderAddress, SetReadyStatus_Func *callResult) {(void) senderAddress; (void) callResult;}
GetReadyStatus_CallbackRoomsCallback754 	virtual void GetReadyStatus_Callback( SystemAddress senderAddress, GetReadyStatus_Func *callResult) {(void) senderAddress; (void) callResult;}
SetRoomLockState_CallbackRoomsCallback755 	virtual void SetRoomLockState_Callback( SystemAddress senderAddress, SetRoomLockState_Func *callResult) {(void) senderAddress; (void) callResult;}
GetRoomLockState_CallbackRoomsCallback756 	virtual void GetRoomLockState_Callback( SystemAddress senderAddress, GetRoomLockState_Func *callResult) {(void) senderAddress; (void) callResult;}
AreAllMembersReady_CallbackRoomsCallback757 	virtual void AreAllMembersReady_Callback( SystemAddress senderAddress, AreAllMembersReady_Func *callResult) {(void) senderAddress; (void) callResult;}
KickMember_CallbackRoomsCallback758 	virtual void KickMember_Callback( SystemAddress senderAddress, KickMember_Func *callResult) {(void) senderAddress; (void) callResult;}
UnbanMember_CallbackRoomsCallback759 	virtual void UnbanMember_Callback( SystemAddress senderAddress, UnbanMember_Func *callResult) {(void) senderAddress; (void) callResult;}
GetBanReason_CallbackRoomsCallback760 	virtual void GetBanReason_Callback( SystemAddress senderAddress, GetBanReason_Func *callResult) {(void) senderAddress; (void) callResult;}
AddUserToQuickJoin_CallbackRoomsCallback761 	virtual void AddUserToQuickJoin_Callback( SystemAddress senderAddress, AddUserToQuickJoin_Func *callResult) {(void) senderAddress; (void) callResult;}
RemoveUserFromQuickJoin_CallbackRoomsCallback762 	virtual void RemoveUserFromQuickJoin_Callback( SystemAddress senderAddress, RemoveUserFromQuickJoin_Func *callResult) {(void) senderAddress; (void) callResult;}
IsInQuickJoin_CallbackRoomsCallback763 	virtual void IsInQuickJoin_Callback( SystemAddress senderAddress, IsInQuickJoin_Func *callResult) {(void) senderAddress; (void) callResult;}
SearchByFilter_CallbackRoomsCallback764 	virtual void SearchByFilter_Callback( SystemAddress senderAddress, SearchByFilter_Func *callResult) {(void) senderAddress; (void) callResult;}
ChangeHandle_CallbackRoomsCallback765 	virtual void ChangeHandle_Callback( SystemAddress senderAddress, ChangeHandle_Func *callResult) {(void) senderAddress; (void) callResult;}
Chat_CallbackRoomsCallback766 	virtual void Chat_Callback( SystemAddress senderAddress, Chat_Func *callResult) {(void) senderAddress; (void) callResult;}
Bitstream_CallbackRoomsCallback767 	virtual void Bitstream_Callback( SystemAddress senderAddress, Bitstream_Func *callResult) {(void) senderAddress; (void) callResult;}
768 	// Notifications due to other room members
QuickJoinExpired_CallbackRoomsCallback769 	virtual void QuickJoinExpired_Callback( SystemAddress senderAddress, QuickJoinExpired_Notification *notification) {(void) senderAddress; (void) notification;}
QuickJoinEnteredRoom_CallbackRoomsCallback770 	virtual void QuickJoinEnteredRoom_Callback( SystemAddress senderAddress, QuickJoinEnteredRoom_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberStartedSpectating_CallbackRoomsCallback771 	virtual void RoomMemberStartedSpectating_Callback( SystemAddress senderAddress, RoomMemberStartedSpectating_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberStoppedSpectating_CallbackRoomsCallback772 	virtual void RoomMemberStoppedSpectating_Callback( SystemAddress senderAddress, RoomMemberStoppedSpectating_Notification *notification) {(void) senderAddress; (void) notification;}
ModeratorChanged_CallbackRoomsCallback773 	virtual void ModeratorChanged_Callback( SystemAddress senderAddress, ModeratorChanged_Notification *notification) {(void) senderAddress; (void) notification;}
SlotCountsSet_CallbackRoomsCallback774 	virtual void SlotCountsSet_Callback( SystemAddress senderAddress, SlotCountsSet_Notification *notification) {(void) senderAddress; (void) notification;}
CustomRoomPropertiesSet_CallbackRoomsCallback775 	virtual void CustomRoomPropertiesSet_Callback( SystemAddress senderAddress, CustomRoomPropertiesSet_Notification *notification) {(void) senderAddress; (void) notification;}
RoomNameSet_CallbackRoomsCallback776 	virtual void RoomNameSet_Callback( SystemAddress senderAddress, RoomNameSet_Notification *notification) {(void) senderAddress; (void) notification;}
HiddenFromSearchesSet_CallbackRoomsCallback777 	virtual void HiddenFromSearchesSet_Callback( SystemAddress senderAddress, HiddenFromSearchesSet_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberReadyStatusSet_CallbackRoomsCallback778 	virtual void RoomMemberReadyStatusSet_Callback( SystemAddress senderAddress, RoomMemberReadyStatusSet_Notification *notification) {(void) senderAddress; (void) notification;}
RoomLockStateSet_CallbackRoomsCallback779 	virtual void RoomLockStateSet_Callback( SystemAddress senderAddress, RoomLockStateSet_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberKicked_CallbackRoomsCallback780 	virtual void RoomMemberKicked_Callback( SystemAddress senderAddress, RoomMemberKicked_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberHandleSet_CallbackRoomsCallback781 	virtual void RoomMemberHandleSet_Callback( SystemAddress senderAddress, RoomMemberHandleSet_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberLeftRoom_CallbackRoomsCallback782 	virtual void RoomMemberLeftRoom_Callback( SystemAddress senderAddress, RoomMemberLeftRoom_Notification *notification) {(void) senderAddress; (void) notification;}
RoomMemberJoinedRoom_CallbackRoomsCallback783 	virtual void RoomMemberJoinedRoom_Callback( SystemAddress senderAddress, RoomMemberJoinedRoom_Notification *notification) {(void) senderAddress; (void) notification;}
RoomInvitationSent_CallbackRoomsCallback784 	virtual void RoomInvitationSent_Callback( SystemAddress senderAddress, RoomInvitationSent_Notification *notification) {(void) senderAddress; (void) notification;}
RoomInvitationWithdrawn_CallbackRoomsCallback785 	virtual void RoomInvitationWithdrawn_Callback( SystemAddress senderAddress, RoomInvitationWithdrawn_Notification *notification) {(void) senderAddress; (void) notification;}
RoomDestroyedOnModeratorLeft_CallbackRoomsCallback786 	virtual void RoomDestroyedOnModeratorLeft_Callback( SystemAddress senderAddress, RoomDestroyedOnModeratorLeft_Notification *notification) {(void) senderAddress; (void) notification;}
Chat_CallbackRoomsCallback787 	virtual void Chat_Callback( SystemAddress senderAddress, Chat_Notification *notification) {(void) senderAddress; (void) notification;}
Bitstream_CallbackRoomsCallback788 	virtual void Bitstream_Callback( SystemAddress senderAddress, Bitstream_Notification *notification) {(void) senderAddress; (void) notification;}
789 };
790 
791 /// \brief Used to create rooms for players where they can matchmake
792 /// \details A room is similar to the rooms you see in other lobby systems, where groups of players can join together in order to start a game match<BR>
793 /// Each player can be in at most one room.<BR>
794 /// Each player name must be unique.<BR>
795 /// Each room has one moderator, which can perform operations on the room such as kicking out members.<BR>
796 /// This plugin networks the AllGamesRoomsContainer class, which performs the actual functionality.<BR>
797 /// <BR>
798 /// To use as a client:<BR>
799 /// <OL>
800 /// <LI>Connect to the server and attach the plugin as normal.
801 /// <LI>Call SetServerAddress to tell the system where the server is.
802 /// <LI>Call RoomsPlugin::SetRoomsCallback() with a pointer to a callback structure
803 /// <LI>Fill in the input parameters of the desired structure(s)
804 /// <LI>Call RoomsPlugin::ExecuteFunc with a pointer to the structure.
805 /// <LI>Process the callback, which will contain the original input parameters, plus the new output parameters. All structures contain resultCode, which indicates if the operation was successful (REC_SUCCESS) or not (Anything else)
806 /// </OL>
807 /// <BR>
808 /// To use as a server:
809 /// <OL>
810 /// <LI>Start RakNet as usual, accepting connections and attaching the plugin
811 /// <LI>Call RoomsPlugin::SetProfanityFilter() with the ProfanityFilter class, if desired
812 /// <LI>Call RoomsPlugin::AddTitle() for each title (game) you want to support
813 /// <LI>If you want other systems to be able to call RoomsPlugin::LoginRoomsParticipant(), call RoomsPlugin::AddLoginServerAddress() with the addresses of those systems
814 /// <LI>As users go online, call RoomsPlugin::LoginRoomsParticipant(). Login and Logoff is up to you to implement (or rely on other systems, such as Lobby2)
815 /// <LI>As users go offline, call RoomsPlugin::LogoffRoomsParticipant();
816 /// </OL>
817 /// \sa AllGamesRoomsContainer
818 /// \ingroup ROOMS_GROUP
819 class RAK_DLL_EXPORT RoomsPlugin : public PluginInterface2, public RoomsCallback
820 {
821 public:
822 	RoomsPlugin();
823 	virtual ~RoomsPlugin();
824 
825 	/// \brief Ordering channel to send messages on
826 	/// \param[in] oc The ordering channel
827 	void SetOrderingChannel(char oc);
828 
829 	/// \brief Send priority to send messages on
830 	/// \param[in] pp The packet priority
831 	void SetSendPriority(PacketPriority pp);
832 
833 	// --------------------------------------------------------------------------------------------
834 	// Client room functions. Will transmit the command to the server specified with SetServerAddress();
835 	// --------------------------------------------------------------------------------------------
836 
837 	/// \brief Set the callback to get notification and ExecuteFunc() results
838 	/// \param[in] _roomsCallback Class instance to get callbacks on. Should remain a valid pointer for the duration of the plugin execution.
839 	void SetRoomsCallback(RoomsCallback *_roomsCallback);
840 
841 	/// \brief Add a callback to get notification and ExecuteFunc() results
842 	/// \param[in] _roomsCallback Class instance to get callbacks on. Should remain a valid pointer for the duration of the plugin execution.
843 	void AddRoomsCallback(RoomsCallback *_roomsCallback);
844 
845 	/// \brief Remove a callback to get notification and ExecuteFunc() results
846 	/// \param[in] _roomsCallback Class instance to no longer get callbacks on.
847 	void RemoveRoomsCallback(RoomsCallback *_roomsCallback);
848 
849 	/// \brief Execute a function, using the system address passed to SetServerAddress();
850 	/// \param[in] func Pointer to a base class of RoomsPluginFunc to execute
851 	void ExecuteFunc(RoomsPluginFunc *func);
852 
853 	/// \brief Execute a function, with a specific address
854 	/// \param[in] func Pointer to a base class of RoomsPluginFunc to execute
855 	/// \param[in] remoteAddress Address to send the command to. The remote system should also be running RoomsPlugin
856 	void ExecuteFunc(RoomsPluginFunc *func, SystemAddress remoteAddress);
857 
858 	/// \brief Sets the remote server address that is running RoomsPlugin. Send calls will go to this function
859 	/// \param[in] systemAddress The remote system, which should be connected while calling client functions
860 	void SetServerAddress( SystemAddress systemAddress );
861 
862 	// --------------------------------------------------------------------------------------------
863 	// Server functions.
864 	// --------------------------------------------------------------------------------------------
865 
866 	/// \brief Add a participant to the system
867 	/// \details Only participants can perform operations
868 	/// \param[in] userName A unique string identifying the user
869 	/// \param[in] roomsParticipantAddress The address of the user
870 	/// \param[in] guid The guid of the user
871 	/// \param[in] loginServerAddress The server adding this user. Use UNASSIGNED_SYSTEM_ADDRESS for not applicable. Otherwise, the address must previously have been added using AddLoginServerAddress() or the function will fail.
872 	bool LoginRoomsParticipant(RakNet::RakString userName, SystemAddress roomsParticipantAddress, RakNetGUID guid, SystemAddress loginServerAddress);
873 
874 	/// \brief Removes a participant from the system
875 	/// \param[in] userName A unique string identifying the user
876 	/// \param[in] loginServerAddress The server removing. Use UNASSIGNED_SYSTEM_ADDRESS for not applicable. Otherwise, the address must previously have been added using AddLoginServerAddress() or the function will fail.
877 	bool LogoffRoomsParticipant(RakNet::RakString userName, SystemAddress loginServerAddress);
878 
879 	/// \brief Clear all users
880 	void ClearRoomMembers();
881 
882 	/// \brief Used for Lobby2. Serializes the same data that the plugin itself uses to login
883 	/// \internal
884 	static void SerializeLogin(RakNet::RakString userName, SystemAddress userAddress, RakNetGUID guid, RakNet::BitStream *bs);
885 
886 	/// \brief Used for Lobby2. Serializes the same data that the plugin itself uses to logoff
887 	/// \internal
888 	static void SerializeLogoff(RakNet::RakString userName, RakNet::BitStream *bs);
889 
890 	/// \brief Used for Lobby2. Serializes the same data that the plugin itself uses to change handles
891 	/// \internal
892 	static void SerializeChangeHandle(RakNet::RakString oldHandle, RakNet::RakString newHandle, RakNet::BitStream *bs);
893 
894 	/// \brief Change the handle a user
895 	/// \param[in] oldHandle The handle previously known by the system
896 	/// \param[in] newHandle The new handle to use
897 	void ChangeHandle(RakNet::RakString oldHandle, RakNet::RakString newHandle);
898 
899 	/// \brief Add a SystemAddress to a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called
900 	/// \param[in] systemAddress The address to add
901 	void AddLoginServerAddress(SystemAddress systemAddress);
902 
903 	/// \brief Remove a SystemAddress from a list that will be checked when LoginRoomsParticipant() and LogoffRoomsParticipant() is called
904 	/// \param[in] systemAddress The address to remove
905 	void RemoveLoginServerAddress(SystemAddress systemAddress);
906 
907 	/// \brief Remove all addresses added with AddLoginServerAddress()
908 	void ClearLoginServerAdddresses(void);
909 
910 	/// \brief Sets the profanity filter for the system to use (optional)
911 	/// \details If set, room names and player handles will be checked for profanity.
912 	/// Room invitations and other messages are not checked.
913 	/// \param[in] pf An instance of a profanity filter
914 	void SetProfanityFilter(ProfanityFilter *pf);
915 
916 	/// \brief Only used on the server. Locally perform any desired functions, such as logging off players
917 	/// \note Use AllGamesRoomsContainer::AddTitle() to add titles
918 	AllGamesRoomsContainer roomsContainer;
919 
920 	// --------------------------------------------------------------------------------------------
921 	// Packet handling functions
922 	// --------------------------------------------------------------------------------------------
923 	/// \internal
924 	virtual void OnDetach(void);
925 	/// \internal
926 	virtual void OnShutdown(void);
927 	/// \internal
928 	virtual void Update(void);
929 	/// \internal
930 	virtual PluginReceiveResult OnReceive(Packet *packet);
931 	/// \internal
932 	virtual void OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
933 
934 protected:
935 	void Clear(void);
936 	bool IsServer(void) const;
937 	void OnRoomsExecuteFunc(Packet *packet);
938 	void OnLoginStatus(Packet *packet);
939 	void OnHandleChange(Packet *packet);
940 
941 	// Client and server data
942 	char orderingChannel;
943 	DataStructures::List<RoomsCallback *> roomsCallback;
944 	PacketPriority packetPriority;
945 	ProfanityFilter *profanityFilter;
946 	RakNetTime lastUpdateTime;
947 
948 	// Client data
949 	SystemAddress serverAddress;
950 
951 	// Server data
952 	// Servers that can remotely trigger LoginRoomMember and LogoffRoomMember
953 	DataStructures::List<SystemAddress> loginServers;
954 	// Logged in room members
955 	struct RoomsPluginParticipant : public RoomsParticipant
956 	{
RoomsPluginParticipantRoomsPluginParticipant957 		RoomsPluginParticipant() {lastRoomJoined=(RoomID)-1;}
958 		RoomID lastRoomJoined;
959 	};
960 	static int RoomsPluginParticipantCompByRakString( const RakNet::RakString &key, RoomsPluginParticipant* const &data );
961 	DataStructures::OrderedList<RakNet::RakString, RoomsPluginParticipant*, RoomsPluginParticipantCompByRakString> roomsParticipants;
962 
963 	RoomsPluginParticipant* GetParticipantByHandle(RakNet::RakString handle, SystemAddress systemAddress);
964 	RoomsPluginParticipant* ValidateUserHandle(RoomsPluginFunc* func, SystemAddress systemAddress);
965 	void ProcessRemoveUserResult(RemoveUserResult *removeUserResult);
966 
967 	virtual void CreateRoom_Callback( SystemAddress senderAddress, CreateRoom_Func *callResult);
968 	virtual void EnterRoom_Callback( SystemAddress senderAddress, EnterRoom_Func *callResult);
969 	virtual void JoinByFilter_Callback( SystemAddress senderAddress, JoinByFilter_Func *callResult);
970 	virtual void LeaveRoom_Callback( SystemAddress senderAddress, LeaveRoom_Func *callResult);
971 	virtual void GetInvitesToParticipant_Callback( SystemAddress senderAddress, GetInvitesToParticipant_Func *callResult);
972 	virtual void SendInvite_Callback( SystemAddress senderAddress, SendInvite_Func *callResult);
973 	virtual void AcceptInvite_Callback( SystemAddress senderAddress, AcceptInvite_Func *callResult);
974 	virtual void StartSpectating_Callback( SystemAddress senderAddress, StartSpectating_Func *callResult);
975 	virtual void StopSpectating_Callback( SystemAddress senderAddress, StopSpectating_Func *callResult);
976 	virtual void GrantModerator_Callback( SystemAddress senderAddress, GrantModerator_Func *callResult);
977 	virtual void ChangeSlotCounts_Callback( SystemAddress senderAddress, ChangeSlotCounts_Func *callResult);
978 	virtual void SetCustomRoomProperties_Callback( SystemAddress senderAddress, SetCustomRoomProperties_Func *callResult);
979 	virtual void GetRoomProperties_Callback( SystemAddress senderAddress, GetRoomProperties_Func *callResult);
980 	virtual void ChangeRoomName_Callback( SystemAddress senderAddress, ChangeRoomName_Func *callResult);
981 	virtual void SetHiddenFromSearches_Callback( SystemAddress senderAddress, SetHiddenFromSearches_Func *callResult);
982 	virtual void SetDestroyOnModeratorLeave_Callback( SystemAddress senderAddress, SetDestroyOnModeratorLeave_Func *callResult);
983 	virtual void SetReadyStatus_Callback( SystemAddress senderAddress, SetReadyStatus_Func *callResult);
984 	virtual void GetReadyStatus_Callback( SystemAddress senderAddress, GetReadyStatus_Func *callResult);
985 	virtual void SetRoomLockState_Callback( SystemAddress senderAddress, SetRoomLockState_Func *callResult);
986 	virtual void GetRoomLockState_Callback( SystemAddress senderAddress, GetRoomLockState_Func *callResult);
987 	virtual void AreAllMembersReady_Callback( SystemAddress senderAddress, AreAllMembersReady_Func *callResult);
988 	virtual void KickMember_Callback( SystemAddress senderAddress, KickMember_Func *callResult);
989 	virtual void UnbanMember_Callback( SystemAddress senderAddress, UnbanMember_Func *callResult);
990 	virtual void GetBanReason_Callback( SystemAddress senderAddress, GetBanReason_Func *callResult);
991 	virtual void AddUserToQuickJoin_Callback( SystemAddress senderAddress, AddUserToQuickJoin_Func *callResult);
992 	virtual void RemoveUserFromQuickJoin_Callback( SystemAddress senderAddress, RemoveUserFromQuickJoin_Func *callResult);
993 	virtual void IsInQuickJoin_Callback( SystemAddress senderAddress, IsInQuickJoin_Func *callResult);
994 	virtual void SearchByFilter_Callback( SystemAddress senderAddress, SearchByFilter_Func *callResult);
995 	virtual void ChangeHandle_Callback( SystemAddress senderAddress, ChangeHandle_Func *callResult);
996 	virtual void Chat_Callback( SystemAddress senderAddress, Chat_Func *callResult);
997 	virtual void Bitstream_Callback( SystemAddress senderAddress, Bitstream_Func *callResult);
998 
999 	void ExecuteNotification(RoomsPluginNotification *func, RoomsPluginParticipant *recipient);
1000 	void ExecuteNotificationToOtherRoomMembers(Room *room, RoomsPluginParticipant* roomsPluginParticipant, RoomsPluginNotification *notification);
1001 };
1002 
1003 /// \ingroup ROOMS_GROUP
1004 enum RoomsPluginOperations
1005 {
1006 	RPO_CREATE_ROOM,
1007 	RPO_ENTER_ROOM,
1008 	RPO_JOIN_BY_FILTER,
1009 	RPO_LEAVE_ROOM,
1010 	RPO_GET_INVITES_TO_PARTICIPANT,
1011 	RPO_SEND_INVITE,
1012 	RPO_ACCEPT_INVITE,
1013 	RPO_START_SPECTATING,
1014 	RPO_STOP_SPECTATING,
1015 	RPO_GRANT_MODERATOR,
1016 	RPO_CHANGE_SLOT_COUNTS,
1017 	RPO_SET_CUSTOM_ROOM_PROPERTIES,
1018 	RPO_GET_ROOM_PROPERTIES,
1019 	RPO_CHANGE_ROOM_NAME,
1020 	RPO_SET_HIDDEN_FROM_SEARCHES,
1021 	RPO_SET_DESTROY_ON_MODERATOR_LEAVE,
1022 	RPO_SET_READY_STATUS,
1023 	RPO_GET_READY_STATUS,
1024 	RPO_SET_ROOM_LOCK_STATE,
1025 	RPO_GET_ROOM_LOCK_STATE,
1026 	RPO_ARE_ALL_MEMBERS_READY,
1027 	RPO_KICK_MEMBER,
1028 	RPO_UNBAN_MEMBER,
1029 	RPO_GET_BAN_REASON,
1030 	RPO_ADD_USER_TO_QUICK_JOIN,
1031 	RPO_REMOVE_USER_FROM_QUICK_JOIN,
1032 	RPO_IS_IN_QUICK_JOIN,
1033 	RPO_SEARCH_BY_FILTER,
1034 	RPO_CHANGE_HANDLE,
1035 	RPO_CHAT,
1036 	RPO_BITSTREAM,
1037 	RPN_QUICK_JOIN_EXPIRED,
1038 	RPN_QUICK_JOIN_ENTERED_ROOM,
1039 	RPN_ROOM_MEMBER_STARTED_SPECTATING,
1040 	RPN_ROOM_MEMBER_STOPPED_SPECTATING,
1041 	RPN_MODERATOR_CHANGED,
1042 	RPN_SLOT_COUNTS_SET,
1043 	RPN_CUSTOM_ROOM_PROPERTIES_SET,
1044 	RPN_ROOM_NAME_SET,
1045 	RPN_HIDDEN_FROM_SEARCHES_SET,
1046 	RPN_ROOM_MEMBER_READY_STATUS_SET,
1047 	RPN_ROOM_LOCK_STATE_SET,
1048 	RPN_ROOM_MEMBER_KICKED,
1049 	RPN_ROOM_MEMBER_HANDLE_SET,
1050 	RPN_ROOM_MEMBER_LEFT_ROOM,
1051 	RPN_ROOM_MEMBER_JOINED_ROOM,
1052 	RPN_ROOM_INVITATION_SENT,
1053 	RPN_ROOM_INVITATION_WITHDRAWN,
1054 	RPN_ROOM_DESTROYED_ON_MODERATOR_LEFT,
1055 	RPN_CHAT_NOTIFICATION,
1056 	RPN_BITSTREAM_NOTIFICATION,
1057 };
1058 
1059 } // namespace RakNet
1060 
1061 #endif
1062