I have the newest Colyseus SDK version in 0.14.8
0
Reputation
2
Posts
531
Profile views
0
Followers
0
Following
Posts made by Unelith
RE: CSAMatchMakeException only thrown sometimes in JoinById
posted in Questions & Help •
CSAMatchMakeException only thrown sometimes in JoinById
posted in Questions & Help •
I'm using the Unity client, with Unity version 2020.3.19f1
.
I'm throwing ServerError
server side in onAuth
, but it's only re-thrown sometimes on the client, as opposed to every time. Most of the time, the async task will just keep hanging there forever and neither resolve nor throw.
The first attempt usually throws correctly (but not quite every single time).
Below is the result of attempting the same action twice in a row, with the same parameters:
Unity log:
Server log:
Client-side code:
try {
// Connect to lobby room
var _room = await colyseus.JoinById<LobbyState>(colyseusSettings.lobbyRoomId, new Dictionary<string, object>{
{ "username", _credentials.username },
{ "password", _credentials.password }
});
} catch ( CSAMatchMakeException ex ) {
if (ex.Code == 401) {
throw new WrongCredentialsException(ex.Message, _credentials.username, _credentials.password);
} else if (ex.Code >= 500) {
throw new LoginServerException(ex.Message);
} else {
throw new LoginUnknownException(ex.Message);
}
} catch ( Exception ex ) {
throw new LoginUnknownException(ex.Message);
}
Server-side code:
if (!account) {
log.debug({ roomType: 'LobbyRoom', roomId: this.roomId, client, username: options.username }, '[LobbyRoom] Client authentication failed - no matching account for provided credentials');
throw new ServerError(401, 'No matching account found for username and password');
}
The entire onAuth
method is async
and returns a Promise<T>
.