class_name Channel
extends Node

const SOCKET_FALLBACK_URL := "ws://localhost:8080/ws"

var socket = WebSocketPeer.new()
var socket_url := OS.get_environment("TD_SERVER_WS")


func get_channel_location() -> String:
	push_error("Not Implemented")
	return ""


func connect_socket(token: String):
	socket.handshake_headers = PackedStringArray(["Authorization: " + token])
	if socket_url == "":
		socket_url = SOCKET_FALLBACK_URL
	socket.connect_to_url(socket_url + "/" + get_channel_location())