Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
This plugin quickly and simply establishes a peer to peer connection within the local broadcast domain automatically.Send simple short commands by using the send() function.Receive simple short commands by connecting to the on_peer_message(msg, data) signal.
LAN Detector
This plugin quickly and simply establishes a peer to peer connection within the local broadcast domain automatically.
It's simple to use:
Server
Attach the script lan_detector_server.gd to your Node, and add it to your scene tree.
This will start a server.
Client
Attach the script lan_detector_client.gd to your Node, and add it to your scene tree.
This will start searching for the server within the local broadcast domain.
Communication
You can send and receive simple short commands by using the send() function and by connecting to the on_peer_message(msg:LANDATA.TYPE, data:Variant) signal.
Here's a basic server example
var server = lan_detector_server
func _ready():
server.on_peer_message.connect(received)
server.on_peer_connected.connect(connected)
func connected():
server.send(LANDATA.TYPE.ECHO, "Hello World")
func received(msg, data):
if msg == LANDATA.TYPE.REPLY:
print("Reply: " + data)
Here's a basic client example
var client = lan_detector_client
func _ready():
client.on_peer_message.connect(received)
func received(msg, data):
if msg == LANDATA.TYPE.ECHO:
client.send(LANDATA.TYPE.REPLY, data)
In the code examples, we assume the following:
- Both
lan_detector_serverandlan_detector_clientare project Autoloads that have each been set to a Node which should have the appropriate script attached. - The
LANDATA.TYPEenum hasECHOandREPLYdefined.
When both the server and client are both running within the same local broadcast domain, they should automatically be established. Once established, the on_peer_connected() signal will be emitted. This causes the server to send an echo to the client, then the client responds back to the server with the data.
Note that the firewall on the server must allow incoming UDP connections Note that you cannot send more than ~1500 bytes as this does not support fragmentation
This plugin quickly and simply establishes a peer to peer connection within the local broadcast domain automatically.
Send simple short commands by using the send() function.
Receive simple short commands by connecting to the on_peer_message(msg, data) signal.
Reviews
Quick Information
This plugin quickly and simply establishes a peer to peer connection within the local broadcast domain automatically.Send simple short commands by using the send() function.Receive simple short commands by connecting to the on_peer_message(msg, data) signal.