The community forums are in BETA and closed to the public.

Room based RT multiplayer game

For a room based multiplayer game, I am searching for the right backend service. This is the functionality I need: a player can create a new room where 1 - 5 other players can join, after that the game is started and no other players can join that room anymore. It also has to be possible to create a new room for FB friends only. Is this possible with PubNub? Because I can't see directly how to do this with PubNub channels.

Yes, this is possible. There is nothing in PubNub SDKs/APIs that directly assist or prevent you from doing this. It is just a design pattern that you must implement into you app's biz logic. Here are some very high level pointers.

  • A player creates a new room. This room can be added to a list of rooms that others can join.
  • When other players look for rooms they can join, you just need to provide some sort of database that keeps a list of these rooms and who created them. When a player queries for these rooms the criteria must be "where creator is one of my friends" (translate that into the query language of your choosing).
  • You need to create this database on your server.
  • You could send an invite (publish a message) to all of the room creator's friends to join the newly created room.
  • When a room's occupancy is 5, do not let anyone else join (use here_now API to get occupancy).

There is some details that you need to work through but this should help you get started.

Login or Signup to post a comment