part 1 - connection
commit
95dba37181
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1,3 @@
|
||||
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
|
||||
dest_md5="26ea799ea0a3da9e753b3ebe822e0570"
|
||||
|
Binary file not shown.
@ -0,0 +1,35 @@
|
||||
extends Node
|
||||
|
||||
const PORT = 8080
|
||||
var _server = WebSocketServer.new()
|
||||
var peers = [] # everyone currently connected
|
||||
|
||||
func _ready():
|
||||
_server.connect('client_connected', self, "_connected")
|
||||
_server.connect('client_disconnected', self, "_disconnected")
|
||||
_server.connect('client_close_request', self, "_close_request")
|
||||
_server.connect("data_received", self, "_on_data_received")
|
||||
|
||||
var err = _server.listen(PORT)
|
||||
if err != OK:
|
||||
print_debug("Unable to start server")
|
||||
set_process(false)
|
||||
print_debug("server started")
|
||||
|
||||
func _connected(id, protocol):
|
||||
print_debug("Client %d connected with protocol: %s"
|
||||
% [id, protocol])
|
||||
|
||||
func _close_request(id, code, reason):
|
||||
print_debug("Client %d disconnecting with code: %d, reason: %s"
|
||||
% [id, code, reason])
|
||||
|
||||
func _disconnected(id, was_clean = false):
|
||||
print_debug("Client %d disconnected, clean: %s"
|
||||
% [id, str(was_clean)])
|
||||
|
||||
func _on_data_received(id):
|
||||
pass
|
||||
|
||||
func _process(_delta):
|
||||
_server.poll()
|
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Server.gd" type="Script" id=1]
|
||||
|
||||
[node name="Server" type="Node"]
|
||||
script = ExtResource( 1 )
|
@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
@ -0,0 +1,24 @@
|
||||
[preset.0]
|
||||
|
||||
name="Linux/X11"
|
||||
platform="Linux/X11"
|
||||
runnable=true
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../Exports/ChatServer.x86_64"
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
binary_format/64_bits=true
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=false
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
texture_format/no_bptc_fallbacks=true
|
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -0,0 +1,32 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="ChatServer"
|
||||
run/main_scene="res://Server.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=100
|
||||
window/size/height=100
|
||||
|
||||
[gui]
|
||||
|
||||
common/drop_mouse_on_gui_input_disabled=true
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
Loading…
Reference in New Issue