32 lines
1.0 KiB
GDScript
32 lines
1.0 KiB
GDScript
extends Control
|
|
|
|
## NETWORK
|
|
func con_suc():#Successful connection
|
|
$chatbox.text+=str(get_tree().network_peer.get_unique_id())+" has connected to the server.\n"
|
|
|
|
func con_fail():#When a connection attempt fails.
|
|
$chatbox.text+="Failed to connect to the server.\n"
|
|
|
|
func con_dis():#When the server disconnects.
|
|
$chatbox.text+="disconnected from the server.\n"
|
|
|
|
func peer_con(id):#when a client connects.
|
|
$chatbox.text+=str(id)+" has connected to the server.\n"
|
|
|
|
func peer_dis(id):#when a client disconnects.
|
|
$chatbox.text+=str(id)+" has disconnected from the server.\n"
|
|
|
|
## CHAT
|
|
|
|
## COMPANY NAME
|
|
|
|
## MAIN
|
|
func _ready():
|
|
var connections = [
|
|
get_tree().network_peer.connect("connection_succeeded",self,"con_suc"),
|
|
get_tree().network_peer.connect("connection_failed",self,"con_fail"),
|
|
get_tree().network_peer.connect("server_disconnected",self,"con_dis"),
|
|
get_tree().network_peer.connect("peer_connected",self,"peer_con"),
|
|
get_tree().network_peer.connect("peer_disconnected",self,"peer_dis")
|
|
]
|
|
print_debug(connections) |