games in real time

bosh77

Member
Joined
Oct 26, 2019
Messages
37
Hi, how can I create an online multiplayer game, where apps can communicate with each other in real time? Is there any example or module with which you can do this?
 
Last edited:

adamredwoods

New member
3rd Party Tool Dev
Joined
Jun 23, 2017
Messages
42
I don't think there's a specific module, but here's a limited example: https://www.cerberus-x.com/communit...ime-co-for-a-turn-based-multiplayer-game.639/

Cerberus X can use websockets, which is a good way to go, not sure if it uses WebRTC.
https://webrtc.org/getting-started/overview

You can do just fine with websockets game, but the difficult part is deciding on a server to maintain game sessions and state. If someone drops off for 3 seconds, how is the game handled? Using a self-hosted (or on AWS, Vultr) server is one way:
https://github.com/colyseus/colyseus

I think there are hosting game servers out there, Google Cloud seems to have one: https://cloud.google.com/game-servers
It would be possible to forego a server, but the two (or more) machines would have to know each other's IP addresses.
 

bosh77

Member
Joined
Oct 26, 2019
Messages
37
Hello, I'm trying to work with sockets but I don't understand how to make communicate my Android device with the computer (forgive my ignorance).
If imposed an IP address different from Localhost, I get the Bind Failed error.
How do I use the IP address of the devices that I want to make communicate with each other?
 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
If both devices share the same lan, it should work. Do they?
 

bosh77

Member
Joined
Oct 26, 2019
Messages
37
I am trying with the example echoserver_tcp.cxs.
When imposed "localhost" as a address it works, but when I use the ip address of the machine it gives me error.

Code:
Class TcpEchoServer Implements IOnAcceptComplete

    Method New(port:Int)
        _socket=New Socket( "server" )
        If Not _socket.Bind(hostx, port) Error "Bind failed"
        _socket.AcceptAsync( Self )
    End
    
    ....

If I impose "hostx" with an IP address I get Bind Failed error, so I can't try on a LAN.

Also I don't have very clear ideas on the functioning of sockets:cry:. My goal is to be able to exchange data between devices to manage a multiplayer game.
 

bosh77

Member
Joined
Oct 26, 2019
Messages
37
If both devices share the same lan, it should work. Do they?
Yes if I use local IP address I can connect my Windows app with my Android device.
But I can't make them communicate via remote IP address
 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
So you have a Server running somewhere that shares the messages between connected devices? So for maybe asking stupid questions. It’s not my field of expertise.
 

bosh77

Member
Joined
Oct 26, 2019
Messages
37
Yes, Windows and Android devices are connected to the home router

The problem is to connect them via remote IP

I am not an expert either

Maybe it is not possible to do as I think

the Bind method of the Socket class does not allow you to connect to a remote IP
 
Last edited:

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
Router<>Server
 

SLotman

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jul 3, 2017
Messages
239
Your router uses just "one" external IP #. If you assign this IP # to all devices, it won't work. You need to use the IPs your router gives your devices, something like '192.168.1.100' - open a command prompt and type "ipconfig /all" to see that on Windows.
 
Top Bottom