heroiclabs / nakama-dart

Pure Dart Client for Nakama Server
https://heroiclabs.com/docs/nakama/client-libraries/dart
157 stars 48 forks source link

web support broken and does not seem to be able to log out even using sessionlogout #105

Open telostia opened 2 months ago

telostia commented 2 months ago

version: latest 1.1.0 flutter version: 3.19.6 dart version: 3.3.4 platform: web problem: flutter app cannot relog in due to session not able to logged out. tried solution: 1)tried sessionLogout 2) setting session to null 3) setting client to null 4) setting websocket to null. result: the nakama server session seems to linger with all the methods tried above force solution: force refresh the web app will remove server session status.

Is there an more elegant solution to this?

telostia commented 2 months ago

this is the code i used : `Future login(String username, String password) async { var session = await NakamaClient.getInstance()! .authenticateEmail(email: username, password: password, create: false);

emit(ApplicationState(session: session, match: state.match));
NakamaWSClient.setSession(session);

}

void logout(Session session) { try { var client = NakamaClient.getInstance(); client?.sessionLogout(session: session); client = null; } catch (onError) { print(onError.toString()); } }`

telostia commented 2 months ago

found the culprit... it was the appbar widget that was causing connections to go berserk. somehow placing the login/logout functions here was causing nakama sockets to not show up on the server debug...

telostia commented 2 months ago

Nope. the issue was due to " await getAccount(session)"... causing an issue for dart client not to relogin.

cause: calling await getAccount(session) Error: {"code":16,"message":"Server key invalid"}