Advice for programming a lobby for a network multiplayer game?

jmasterx
  • Advice for programming a lobby for a network multiplayer game? jmasterx

    I'm working on learning network programming. I'm working on a simple card game. The basic idea is:

    Players enter the lobby
    Players see tables
    Players sit at an empty seat
    

    Once they sit, they do not need any information from the lobby, they see the card table and the data about the other players and so forth.

    I've programmed the server portion for the game itself. The clients connect to my server object and the server then receives and sends messages; quite simple.

    The tricky concepts for me are:

    What's a good way to run many tables at the same time?
    What's a good way to keep the lobby consistently updated for each person in the lobby (eg: MSG_TABLE_FILLED, 22)
    

    Ideally I'd like to have 1 server exe for all of this and to have to deal with multithreading as little as possible.

    I'm going to use the enet library.

    I was thinking that each time a game session starts, I push a new Game and I map the client IPs to that table, then I just route messages from those clients to that Game.

    Since enet supports channels I was thinking of using 2 channels per table, one for the game messages and one for in game chat.

    Would something like this work?

    Does anyone have any advice / design ideas for a game with a lobby and many tables? Is there a usual way this is done that I'm overlooking?

    Any conceptual ideas or even c/c++ code examples would be very helpful.

    Thanks

  • First, don't use the IP address. IP addresses can change and UDP is stateless. Instead, assign each client a session and have them pass the session ID back to you in each message. The enet library already does this. The event structure will tell you the ID of the client.

    You'll need to keep a structure for each peer. That should include whether the peer is in a game or not, and if so which game they are in. Also store in the game structure a table of which peers are in that game.

    When a message is sent to the lobby, iterate over the table of peers (or a table just of peers in the lobby) and send the message to each peer. When a game message is received, look up which game that peer is in, and send the message to the handler function for that game object.

    I'm not sure what else to tell you at such a high level.

Tags
c++ c networking
Related questions and answers
  • them to be attached to the node in most cases, even if I allow setting global lights to the scene. @Nicol: Yes that's what I'm trying to figure out. You can see the code doesn't rely on any hardware... I was thinking about making smaller structures with the fTime variable each so I can have attribute keyframes, light keyframes and buffer keyframes, then make the node structure look like... know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I

  • with the Physics correctly... So my main question is: What would be a good combination of libraries to make an online game with? Im sure that many people have good combinations of libraries for making a game... better. I would also like compatability, If Theres one that fits DirectX(at least 9) and OpenGL, then that would be good) 2D Graphics(I liked SFML, so it its possible to get something that works with SFML...Lately I have been working on a game that i plan to make online. I have used different libraries to make this game as far as i could, but I feel that I should rethink on how Im sertting this game up

  • I'm looking into designing and implementing an online RPG (or more accurately, redesigning an existing piece of server software). One of the problems is that of managing visibility. Update data for other players should only be sent to a game client if their player is near the other players (i.e. you shouldn't get health updates for people you can't see on the other side of the map). The main problem is that if you had to compare all the players every time an update is sent, it would just take way too long as the number of players scales (think up to a few thousand players per map and each

  • ) have a separate thread to handle the network sockets, distinct from the rest of the engine which handles the graphics loop and scripting. I did have one potential way to make a networked game... the server. But I'm a little confused about the best way to communicate between the game code and the network code. The networking thread will push the received packet to a queue, and the game thread will read from the queue at the appropriate time during its loop, so we haven't gotten rid of this up-to-one-frame delay. Also, it seems like I would want the thread which handles the sending of packets

  • this summer and I have a good grounding on the web side of things. I've also done some very basic c++ (what i would consider basic). My c++ skills basically comes down to different tutorials on things... in the world. I'm OK at C++ but its one language I would really like to explore and make my primary language. (assuming there are jobs for grads in this area) This project will most likely define the career... i seek out to make this not just a passable project but one that'll be demo-able and I can stand proud beside. What advice can you give to someone like me that you wish someone had told you

  • I'm working on mobile platforms as Android, IOS... Many users of Moblox ask us a windows and an OS X version. There is no difficulties to provide these versions, because we are developing on OS X C++ code but we miss global scores and social network part (facebook, twitter). Is there any library to implement these functions on Desktops plaforms ? On mobile platforms, we have many SDK to provide theses functions as OpenFeint, ScoreLoop, Plus+. We have used cocoslive and uploaded scores with libcurl but it's very limited.

  • After spending time today to jot down some notes regarding the implementation of walls into my tile-based game, I've suddenly realized it's not going to be as simple as I imagined before. While the current stage of my work is not even close to actually making the wall-related code, I've come up with three different ways to do it. Right now I'm unsure which one of my ideas will work best... the players double-wall the whole map, I'm going to beat them to it. Every wall has two halves that are attached to the edge of the tile from inside. So, to make a single "Wall unit" I'll have to create

  • Possible Duplicate: What are good games to “earn your wings” with? Hai, I'm new to the genre "Creating Games".Previously i had done only porting.I need some suggestion's for making a game. What are the basic game logics i need to start with? - Should i write Tic-Tac-Toe game? - Actually this seem very basic to me. I'm totally confused on where to start with.I like to create big games but after starting i feel the game is too heavy to handle. Can any one list out the basic needs of a Game Play programmer? I don't mind using any platform (Flash,c

  • be categorized as premature optimization, but I don't want to eventually find out that it is horribly slow. Any design suggestions / comments would be welcome. Does it seem like a good idea to try...My game will be made up of objects. Essentially the level editor will give me a bunch of objects to choose from and I can drag them in and thus a level is made. The objects could have animation... Unanimated movable objects So first I was thinking of, when the level starts, build a quadtree for all non-movable objects. This way I can easily avoid rendering ones which are not in view. Then from

Data information