Leaving and game starting works rudimentarily
This commit is contained in:
parent
41e7769249
commit
2aea604aba
|
@ -32,7 +32,6 @@ signal connection_failure
|
|||
signal disconnected
|
||||
|
||||
onready var websocket: WebSocketClient = WebSocketClient.new()
|
||||
# TODO: setget these?
|
||||
onready var client_id = null
|
||||
onready var display_name = DEFAULT_DISPLAY_NAME setget set_display_name
|
||||
onready var peer_id = null
|
||||
|
|
|
@ -3,6 +3,7 @@ extends Node2D
|
|||
onready var player = preload("res://objects/player.tscn")
|
||||
|
||||
func _ready():
|
||||
# TODO: probably have to wait for all peers to be ready before we add players
|
||||
rpc("add_player", get_tree().get_network_unique_id())
|
||||
|
||||
func _process(delta):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
extends Control
|
||||
|
||||
# TODO: rename to server browser
|
||||
|
||||
onready var is_loaded = false
|
||||
|
||||
onready var lobbies_grid = $v/body/p/lobbies
|
||||
|
@ -58,7 +56,6 @@ func _on_join_pressed():
|
|||
Global.signaller_client.join_lobby(lobbies.get_item_metadata(items[0])["id"])
|
||||
|
||||
func _lobby_data(new_lobbies: Array):
|
||||
# TODO: handle scrolling so that the user is never too jarred (like chat)
|
||||
for l in new_lobbies:
|
||||
if lobbies.has(l.id): _update_lobby(l.id, l)
|
||||
else: _add_lobby(l.id, l)
|
||||
|
|
|
@ -141,6 +141,7 @@ remotesync func set_ready(ready):
|
|||
var from = get_tree().get_rpc_sender_id()
|
||||
print(from)
|
||||
peer_by_peer_id(from).ready = ready
|
||||
if is_host: update_can_start()
|
||||
|
||||
func _on_TextEdit_text_entered(_new_text):
|
||||
if !send_button.disabled:
|
||||
|
|
|
@ -8,7 +8,7 @@ type ID = string;
|
|||
// app state
|
||||
const allLobbies = new Map<ID, Lobby>();
|
||||
const allClients = new Map<ID, Client>();
|
||||
// TODO: client index by id
|
||||
// TODO: client index by id?
|
||||
|
||||
interface DataMessage {
|
||||
type: string;
|
||||
|
@ -336,7 +336,7 @@ function parseMessage(message: string): { type: string; data?: ServerData } {
|
|||
|
||||
// events
|
||||
function onMessage(client: Client, ev: MessageEvent) {
|
||||
// TODO: log who from?
|
||||
// TODO: log who from? IPs etc.?
|
||||
const msg = parseMessage(ev.data);
|
||||
if (msg.type === "pong") return;
|
||||
console.log("Client Message Received", msg);
|
||||
|
|
Loading…
Reference in a new issue