summaryrefslogtreecommitdiff
path: root/network/login_server.gd
blob: 238a1832200b43cfa948237ad761a311377711bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class_name LoginServer
extends Server


signal logged_in(packet: LoginServerLoginSuccessPacket)


@warning_ignore("shadowed_variable")
func _init(host: String, port: int = 6900) -> void:
	super._init(host, port)


func login(username: String, password: String):
	var login_server_login_packet = LoginServerLoginPacket.new()
	login_server_login_packet.username = username
	login_server_login_packet.password = password
	
	peer.put_data(login_server_login_packet.to_bytes())
	
	var packet = await received_packet
	if packet is LoginServerLoginSuccessPacket:
		print(inst_to_dict(packet))
		logged_in.emit(packet)