- Are custom IDisconnectionReason supported?
Do I need to register them in the client, like how custom error codes are registered with SFSErrorCodes.SetErrorMessage?
Are there any values other than the ones defined by ClientDisconnectionReason that the custom values cannot overlap with?
This is my IDisconnectionReason implementation:
Code: Select all
public enum MyCustomDisconnectReason implements IDisconnectionReason {
JOIN_ROOM_FAILED(100),
ROOM_DESTROYED(101);
private final int value;
MyCustomDisconnectReason(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public byte getByteValue() {
//noinspection NumericCastThatLosesPrecision
return (byte) value;
}
}
This is how I use it (edited for brevity):
Code: Select all
public void handleServerEvent(ISFSEvent event) {
User user = (User) event.getParameter(SFSEventParam.USER);
try {
getApi().joinRoom(user, getRoomToJoin(user.getSession()));
} catch (SFSCreateRoomException | SFSJoinRoomException exception) {
user.disconnect(MyCustomDisconnectReason.JOIN_ROOM_FAILED);
}
}