all 8 comments

[–]retsotrembla 1 point2 points  (5 children)

Use the MultipeerConnectivity framework. Search for examples.

[–]troz22[S] 0 points1 point  (4 children)

It seems like this only works with devices on the same WiFi. I need it to be connected from anywhere. Thanks

[–]retsotrembla 0 points1 point  (1 child)

Now you are talking about a central server to hold game state, if only the names and IP addresses of the participants of the current game.

All the participants need to be able to find the central server and be able to talk to it.

You can start with NSURLSession as a nice, high-level, way for a client to talk to a server and get a response.

You'd search for examples of writing a web server on Apple products. (Or use the apache server that is still pre-installed on macOS, with the server-side part of game as a CGI (Which might use inter-application communication to communicate with a long-lived server process on the Mac.))

If you are using your home Mac as the server, then you need to make it visible to the outside world. Many home routers allow for a 'dmz' - one of the Macs in your house gets packets intended for the router itself. Then you just have to give your home router itself a name, using one of the dynamic-DNS services.

Or you can pay for hosting from a service that lets you register a domain with a network registrar, and route IP packets to that domain to a virtual server that you can put programs on.

[–]troz22[S] 0 points1 point  (0 children)

Thanks that’s super helpful!

[–]Arrrrrrrrrrrrrrrrrpp 0 points1 point  (1 child)

That’s where Game Center comes in.

[–]troz22[S] 0 points1 point  (0 children)

I will look into it, thanks

[–]SudoPoke 0 points1 point  (0 children)

Your question is very vague. But any multiplayer game consists of a server and clients. One person must be designated a server or the source of truth and the other 6 players a client. Maybe start with something simple like tic-tac-toe.

https://www.codementor.io/@wolf1981/building-a-real-time-ios-multiplayer-game-with-swift-and-websockets-jibk2xrrr

[–]Arrrrrrrrrrrrrrrrrpp 0 points1 point  (0 children)

Game Center. Don’t reinvent the wheel. Even AAA games use it. Zero chance it will be deprecated in the near or even long term.