Author Topic: New and improved lobby system coming soon  (Read 5757 times)

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
New and improved lobby system coming soon
« on: August 16, 2008, 10:31:43 AM »
Just a heads up to people interested in RakNet's lobby system.

The current system is good, but the design is very hard to maintain and is extremely time consuming to extend. Expect a rewrite soon. If you plan to use the lobby system, I recommend waiting a short while. It will be a minimum of two weeks but probably not much longer.

Ludi

  • Not-a-newbie
  • *
  • Posts: 19
  • Karma: 0
    • View Profile
Re: New and improved lobby system coming soon
« Reply #1 on: August 17, 2008, 04:23:02 PM »
Hi,

could you explain a little more about the new system? Have you already finished the design and implement it, or is there still the possibility to discuss it?

Well, I don't know how the new design is going to look, but here are some suggestions how I would implement it. First of all, the lobby system would be compleltly controlled by simple and small "plugins". Basically, the lobby system is just the core application (a list of players and their status, the interface to the db, and a set of functions to communicate with it via the plugins), which you can extend with your own plugins, like authenification, chats, friend lists, etc. So it's going to work like the raknet plugin system. You start the lobby server, attach your needed plugins (and ignore the unwanted), same on the client side. (so, every plugin has two parts, a client and a server side)

You can have a simple login plugin, which only checks your id and password, you can have an advanced login plugin with cd code validation. The registration will be a seperate plugin, which you can adapt to your own needs. If you want match making, add a match making plugin, otherwise discard it, etc.

First of all, this would be much easier to maintain, as you have a much more simpler interface (every plugin is only responsible for it's stuff, and you don't have a mega-uber-lobby class). And it will be much easier to extend it with custom plugins. E.g. i wanted to implement an "Achievment System", but it's with the current design it's nearly impossible to do.

Well, the downside of such a system is, that it needs a lot of brain-power to do it smart and to do it right, but it works, you'll get lots of benefits from it.

So, nuff written  ;D

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: New and improved lobby system coming soon
« Reply #2 on: August 17, 2008, 09:40:21 PM »
There's two major parts, rooms and everything else.

For the rooms, I'm going to make it its own plugin. Rooms are contained totally in memory.

Everything else is in the database. Every client operation is represented by a structure that contains the input and output parameters. It also has a function to do the database processing. So the same structure is used on both the client and server. Except for the list of logged on users, the database is not mirrored in memory at all.

The database component on the C++ side is just an interface to network the structures, and run the structures in thread pools.

So yes, it's very easy to add. All you have to do is write more structures. The server and client components know the interface for the structures, but not what structures there are.

I'm still trying to find a competent and affordable database programmer to do that part of it. While I know enough to get by, I want to make something good enough to host millions of players if need be.

Ludi

  • Not-a-newbie
  • *
  • Posts: 19
  • Karma: 0
    • View Profile
Re: New and improved lobby system coming soon
« Reply #3 on: August 18, 2008, 07:27:43 AM »
Okay, could you explain a little bit more in depth, how we can extend the current system. E.g. let's say we have an achievement system (and a pretty simple sample). On the server side in the db, let's say we need one table, were we store the kills for every player (StatsTable) and we need one table, where we list all the gained achievements for every player (AchTable).

So, the client interface would only contain two functions, e.g. "UploadPlayerStats(PlayerId, Stats)", this would only be allowed to be done by authorized servers, and "DownloadPlayerAchievemnts(Playerid)", and perhaps an Event, which get's called, when we gain a new achievement.

So, the server side would be trivial too (but still a lot of work), we just get the stats, check if there's a new achievement, if yes, we store it in the db and shoot the Event, if the player is still online.

Now the questions: How can we integrate somehing like this? And can we just write it down into our own lib and "attach" it somehow to the lobby server/client, so we only have to change it, when the interface changes, or do we have to "hack" this into LobbyClient/LobbyServer, so we need to port it everytime a new raknet version comes out? That's why I asked about a plugin interface before. It seems like structure system that you mentioned is basically the same, just from another point of view, so I would like to see some sort of example for it :)

This way, it would be easy to implement requests, that I had before for the lobby server, e.g. the I wanted a function, which checks, if a name is free for use, before you try to register. In this case, i would copy over RegistrationServer/client class into my code, rename it, add the new message for it, write the client/server code and attach it instead of the "stock" Registration" plugin.


Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: New and improved lobby system coming soon
« Reply #4 on: August 18, 2008, 09:22:31 AM »
I assume you are talking about how to extend the new system.

There is a class factory which you register with the system to create a function object given an ID. When you register the factory, you would pass a derived implementation that contains both the built-in functions and the extended function objects that you define yourself. This way you can add new functionality that is completely contained to the function object. The callbacks and thread pooling will work automatically.

I haven't thought through how to extend existing objects yet. Most likely I will add the ability to intercept a function object creation request that lets you return a derived or different function object with extended functionality.

« Last Edit: August 18, 2008, 09:28:00 AM by Rak'kar »

Ludi

  • Not-a-newbie
  • *
  • Posts: 19
  • Karma: 0
    • View Profile
Re: New and improved lobby system coming soon
« Reply #5 on: August 18, 2008, 10:32:55 AM »
Yes, I was talking about how to extend the new system, sorry for making it not more clear.

It seems like I finally understood, how your new system is going to work. It seems like our both ideas are pretty much the same, you have objects, which you sent over the network and do the logic, my idea was to have client/server classes, which do the logic. Two ways, which lead to the same end :)

So, basically it's going to work like this? :

Code: [Select]
struct PlayerStat : LobbyObject
{
  PlayerStat() :
    LobbyObject(OBJECT_PLAYER_STAT)
  {
  }

  int playerKills;

  void Serialize(Packet *p);
  void Deserilize(Packet *p);
  ...

  void DoClientStuff();
  void DoServerStuff();
}

So, on the clientside, you would have a function Like:

void UplodatePlayerStats(PlayerId id, int kills)
{
  PlayerStatObject stat;

  stat.playerid = id
  stat.kills = kills

  SendObjectToServer(&stat)
}

Is this how we can expect it to work?

Quote
I haven't thought through how to extend existing objects yet. Most likely I will add the ability to intercept a function object creation request that lets you return a derived or different function object with extended functionality.

What about the possibility to overwrite existing  IDs? So basically, if I want to change an object, I copy the existing code into my project, modify it to fit my needs, give it the same id and overwrite the existing object for this id in the factory.

Das Gurke

  • Not-a-newbie
  • *
  • Posts: 45
  • Karma: 3
    • View Profile
    • Freak-Und-Informatiker.de
Re: New and improved lobby system coming soon
« Reply #6 on: August 18, 2008, 11:26:13 AM »
Oke, I will hold my breath =)

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: New and improved lobby system coming soon
« Reply #7 on: August 18, 2008, 05:30:31 PM »
Yes, of course you can overwrite existing IDs if you are going to modify the code.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: New and improved lobby system coming soon
« Reply #8 on: August 30, 2008, 09:10:37 PM »
Here's a list of the new functions:

Code: [Select]
1. System_CreateDatabase (Admin command)
2. System_DestroyDatabase (Admin command)
3. System_CreateTitle (Admin command)
4. System_DestroyTitle (Admin command)
5. System_GetTitleRequiredAge
6. System_GetTitleBinaryData
7. System_RegisterProfanity (Admin command)
8. System_BanUser (Admin command)
9. System_UnbanUser (Admin command)
10. CDKey_Add (Admin command)
11. CDKey_GetStatus (Admin command)
12. CDKey_Use (Admin command)
13. CDKey_FlagStolen (Admin command)
14. Client_Login
15. Client_Logoff
16. Client_RegisterAccount
17. System_SetEmailAddressValidated (Admin command)
18. Client_ValidateHandle
19. Client_DeleteAccount
20. System_PruneAccounts
21. Client_GetEmailAddress
22. Client_GetPasswordRecoveryQuestionByHandle
23. Client_GetPasswordRecoveryAnswerWithQuestion
24. Client_ChangeHandle
25. Client_UpdateAccount
26. Client_StartIgnore
27. Client_StopIgnore
28. Client_GetIgnoreList
29. Friends_SendInvite
30. Friends_AcceptInvite
31. Friends_RejectInvite
32. Friends_GetInvites
33. Friends_GetStatus
34. Friends_Remove
35. RecentUsers_Add
36. RecentUsers_Get
37. Emails_Send
38. Emails_Get
39. Emails_Delete
40. Emails_SetStatus
41. Emails_SetWasRead
42. Ranking_SubmitMatch
43. Ranking_GetMatches
44. Ranking_GetMatchBinaryData
45. Ranking_GetTotalScore
46. Ranking_WipeScoresForPlayer
47. Ranking_WipeMatches
48. Ranking_PruneMatches
49. Ranking_UpdateRating
50. Ranking_WipeRatings
51. Ranking_GetRating
52. Clans_Create
53. Clans_SetProperties
54. Clans_GetProperties
55. Clans_SetMyMemberProperties
56. Clans_GrantLeader
57. Clans_SetSubleaderStatus
58. Clans_SetMemberRank
59. Clans_GetMemberProperties
60. Clans_ChangeHandle
61. Clans_Leave
62. Clans_Get
63. Clans_SendJoinInvitation
64. Clans_WithdrawJoinInvitation
65. Clans_AcceptJoinInvitation
66. Clans_RejectJoinInvitation
67. Clans_DownloadInvitationList
68. Clans_SendJoinRequest
69. Clans_WithdrawJoinRequest
70. Clans_AcceptJoinRequest
71. Clans_RejectJoinRequest
72. Clans_DownloadRequestList
73. Clans_KickAndBlacklistUser
74. Clans_UnblacklistUser
75. Clans_GetBlacklist
76. Clans_GetMembers
77. Clans_CreateBoard
78. Clans_DestroyBoard
79. Clans_CreateNewTopic
80. Clans_ReplyToTopic
81. Clans_RemovePost
82. Clans_GetBoards
83. Clans_GetTopics
84. Clans_GetPosts

A lot of the code is in source control already. All the C++ will be done within a few days. After that it's just waiting for the database calls to get done.