Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

LAN Detector

An asset by jmscreation
The page banner background of a mountain and forest
LAN Detector hero image

Quick Information

0 ratings
LAN Detector icon image
jmscreation
LAN Detector

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.

Supported Engine Version
4.1
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
1 day ago
Git URL
Issue URL

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_server and lan_detector_client are project Autoloads that have each been set to a Node which should have the appropriate script attached.
  • The LANDATA.TYPE enum has ECHO and REPLY defined.

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

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
LAN Detector icon image
jmscreation
LAN Detector

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.

Supported Engine Version
4.1
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
1 day ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers