Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ws.get_close_code always return 0 #217

Open
grusad opened this issue Dec 3, 2024 · 1 comment
Open

_ws.get_close_code always return 0 #217

grusad opened this issue Dec 3, 2024 · 1 comment

Comments

@grusad
Copy link

grusad commented Dec 3, 2024

When i disconnect a user from my server like so:

nk.SessionDisconnect(ctx, presence.Presence.GetSessionId(), 10)

The last argument (10) represents a disconnection code.

This argument should be catched by _ws.get_close_code inside NakamaSocketAdapter.gd

`func _process(delta):
if _ws.get_ready_state() != WebSocketPeer.STATE_CLOSED:
_ws.poll()

var state = _ws.get_ready_state()
if _ws_last_state != state:
	_ws_last_state = state
	if state == WebSocketPeer.STATE_OPEN:
		connected.emit()
	elif state == WebSocketPeer.STATE_CLOSED:
		var code = _ws.get_close_code()
		var reason = _ws.get_close_reason()
		print("WebSocket closed with code: %d, reason %s. Clean: %s" % [code, reason, code != -1])

		closed.emit()

if state == WebSocketPeer.STATE_CONNECTING:
	if _start + _timeout < Time.get_unix_time_from_system():
		logger.debug("Timeout when connecting to socket")
		received_error.emit(ERR_TIMEOUT)
		_ws.close()

while _ws.get_ready_state() == WebSocketPeer.STATE_OPEN and _ws.get_available_packet_count():
	received.emit(_ws.get_packet())

`

For whatever reason the code is always 0. I do see in the master branch at least, the _ws.get_close_code() has been removed from the _process-function.

What is really going on here?

Copy link

linear bot commented Dec 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant