Code Monkey home page Code Monkey logo

godothub_client's Introduction

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 : GodotHub NodeJS Server

Implementation

The class for the client is in scripts/godothub.gd . Copy and load it into your game through script.

extends Node

onready 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

obj.disconnect()

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.

godothub_client's People

Contributors

windastella avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.