c++ - Create PHP P2P game client tracker -


at moment i'm looking creating networked game using p2p. game not high paced , don't have access dedicated server, p2p seems choice me. have access online domain. programming done in c++.

oblivious perils of game networking thought p2p did not need sort of centralized server communication. thought 'but how on earth can find other game users hosting game without knowing ip?'. thought need kind of central 'hub' game can connect list of available peer hosts ip , port. connect host , send data using udp (i know it's connectionless, seems enet has tricks that). if idea absurd, let me know.

i had idea make simple php client-ip-switch-thingy on online domain. game won't attract more 2 3 people because it's personal learning goals load on domain won't of issue, think. problem can't find usable information on making of sort using php. tried through 'similar questions' bit of so, still can't find lot of info.

my question is: how can create php game client/host tracker, if possible @ all? know websites or articles on this?

on side note, i'm looking use combination of enet , sfml, enet reliable udp packet , sfml packet builder. viable choice?

as always, several choices acceptable want do.

using p2p connections tricky can powerfull, in low-latency fields such voip , multiplayer online games.

i think need expose server handle informations , states related connected players. recommend using c++ part , boost::asio networking, find plenty of explained examples using two, might find them very robust , scalable. in end, you.

this component have role of accepting incoming connections gamers join or create game. hold list of games , users connected , make them available new incoming players.

pretty simple, isn't ? comes choice have make gaming architecture. choices here using p2p connection between players, or using server proxy between each player.

the server proxy

the server holding informations each game , players can used forward connections between players. rather inneficient in terms of scalability , performance because creating single point of failure server, requirements regarding domain low, option you.

in case, server accept new connection (on socket instance) when player wants join game , broadcast messages other players in game receive advert when player joins, moves, shoots ...

a peer-to-peer connection

that's bit trickier. server serve purpose of knowing players , games existing, instead of having responsability manage connections between users itself, tell player wants join game "hey, you're join new game, if you'd to, please contact 10.20.30.40". public ip address of guy "hosting" game.

you hit first big difficulty. how going communicate host if he's behind router ? you'll need implement nat-traversal capabilities on client side allow incoming player computer hosts game between router.

some techniques used voip apps resolve issue (think skype) when use upnp's igd (internet gateway device) ask router open , redirect port wanted computer. tricky, because takes time , not implemented on every router, potentially lead complete failure. sake of example, let's can overcome issue , let's next one.

when connected computed hosting game, can ask him other players connected game , advert other players connected. idea here have every player in match talking each other updates (again, moves, shots, private messages or whatever), in order keep every player in sync (and trust me won't). might want implement ordering packet algorithm (preferably using udp or enet) in define how adverts , messages broadcasted other players.

take example match 4 players connected to. there host bob, alice neighbour, tom guy living in new york , mike guy need purpose of example.

alice connects bob's game first, adverts bob joined game, on every updates bob , alice exchanging informations current state of match. tom comes in , tells bob he's new player, bob tells tom there 1 other player connected , gives him ip address (alice's). bob tells alice connected , gives ip address. imagine bob dies, bob tell alice died because used talk in first place before tom kicks in, , alice needs tell tom bob died.

you have players broadcast every players every advert rather huge amount of data process, , not scalable given number of players in match. using graph communication in p2p environment far more efficient take far more minutes explained.

i gave point of view these techniques, use classic client-server architecture if want stay simple, giving load you'll need handle, more acceptable.

enjoy ;)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -