Skip to content

_ws.get_close_code always return 0 #217

@grusad

Description

@grusad

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions