Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/windastella/godothub_client
GodotHub Client Class, Multiplayer and network messaging for Godot
https://github.com/windastella/godothub_client
client-side godot godothub-client lobby multiplayer
Last synced: 3 months ago
JSON representation
GodotHub Client Class, Multiplayer and network messaging for Godot
- Host: GitHub
- URL: https://github.com/windastella/godothub_client
- Owner: Windastella
- License: mit
- Created: 2017-01-27T18:32:11.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-15T14:01:37.000Z (over 5 years ago)
- Last Synced: 2023-03-02T06:22:29.169Z (almost 2 years ago)
- Topics: client-side, godot, godothub-client, lobby, multiplayer
- Language: GAP
- Size: 18.6 KB
- Stars: 17
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Godot GodotHub Class API
Multiplayer and network messaging Server for Godot.
The Godot Client code are in written as class which can be instanced through script.
The main idea of GodotHub is to have a thin server that only handle the connection and broadcast the data to channel(lobby).
[GodotHub](https://github.com/Windastella/godothub) : GodotHub NodeJS Server
## Implementation
The class for the client is in scripts/godothub.gd . Copy and load it into your game through script.
```
extends Nodeonready var godothub = preload('scripts/godothub.gd')
onready var conn = godothub.new()func _ready():
set_process(true)# Connect to message signal of godothub to callback
conn.connect("message",self,"_on_receive")func _process(dt):
# Listening for packet
conn.is_listening()# Callback for receiving incoming packet
func _on_receive(data):
print("Receive Data: ",data)```
## API
### Methods
#### .new
` var obj = godothub.new( serverport, serverhost, channel, clientport) `
Initialize the godothub object.
`serverport` Port of the Server. Default: 5000
`serverhost` Host Address of Server. Default: localhost
`channel` Initial Lobby or Room. Default: global
`clientport` Client's listen port. Default: 4000
#### .is_listening
` obj.is_listening() `
Listen for packet.
Return: boolean
#### .change_channel
` obj.change_channel(channel) `
Leave current channel and Join new channel. Creating new channel if the channel does not exist yet.
`channel` lobby you are changing to.
#### .broadcast
` obj.broadcast(data) `
Send data to the server and all clients.
`data` The data are formatted into JSON format.
#### .multicast
` obj.multicast(data) `
Send data to the server and all client in current channel.
`data` The data are formatted into JSON format.
#### .unicast
` obj.unicast(data, ID) `
Send data to the server and to specified client.
`data` The data are formatted into JSON format.
`ID` The ID of targeted client.
#### .disconnect_server
` obj.disconnect_server() `
Disconnect from server.
### Signals
#### error(err)
Triggered when connection return error.
#### connected
Triggered if connection successful.
#### join(id)
Triggered when new client joined the channel.
`id` is the id of the new client.
#### left(id)
Triggered when a client left the channel.
`id` is the id of the leaving client.
#### message(data)
Triggered when data arrived.
`data` The received data.