Skip to content

Use ReactionManager as a dependency of WebSocketSplendorServer #47

@kestivvi

Description

@kestivvi

It would be more readable and safer if we would use ReactionManager to get the classes related to the type of the client request. Or create entirely new class like ReactionRepository, and convert class ReactionManager to some ReactionLoader so the concern of loading and storing are separated.

By throwing exception instead of returning null, this exception can be caught in the onError method, thus making onMessage more readable.

// Get the type of the message
String type = receivedMessage.getType();
// Find appropriate reaction to the message type received
// TODO: It could be more readable if we use some ReactionRepository with get method that would throws exception instead of null
Class<? extends Reaction> reactionClass = reactions.get(type);
if (reactionClass == null) {
Log.TRACE("Unknown reaction type: " + type);
ErrorResponse response = new ErrorResponse(Result.FAILURE, "This message type has not been found!");
webSocket.send(response.ToJson());
return;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: 🙃🙃🙃Above average taskscope: 🛠️it's job for developerstype: refactorno change in functionality, but in mechanizm under the hood, improving performance or security

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions