Skip to content

Commit

Permalink
Update ActiveMQServer.java
Browse files Browse the repository at this point in the history
  • Loading branch information
nicho92 authored Sep 13, 2023
1 parent b579002 commit 68a0089
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/magic/servers/impl/ActiveMQServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public boolean validateUser(String user, String password) {
plug = new ActiveMQServerPlugin() {

JsonExport serializer = new JsonExport();
Set<String> onlines = new HashSet<>();
Set<Player> onlines = new HashSet<>();
Set<Queue> queues = new HashSet<>();


public Set<String> getOnlines() {
public Set<Player> getOnlines() {
return onlines;
}

Expand All @@ -125,13 +125,12 @@ public Set<Queue> getQueues() {
@Override
public void afterCreateSession(ServerSession session) throws ActiveMQException {
logger.info("new connection from user : {} with id {}", session.getUsername(), session.getRemotingConnection().getClientID());
onlines.add(session.getRemotingConnection().getClientID());
}

@Override
public void afterCloseSession(ServerSession session, boolean failed) throws ActiveMQException {
logger.info("disconnection from user : {}", BeanTools.describe(session));
onlines.remove(session.getRemotingConnection().getClientID());
onlines.removeIf(p->session.getRemotingConnection().getClientID().equals(p.getId().toString()));
}


Expand All @@ -157,8 +156,12 @@ public void afterSend(ServerSession session, Transaction tx, Message message, bo
var s = new String(removeNullByte(bytes));
s = s.substring(s.indexOf("{"));
var jmsg = serializer.fromJson(s, JsonMessage.class);


onlines.add(jmsg.getAuthor());

TechnicalServiceManager.inst().store(jmsg);
logger.info("message send from user {} : {}", session.getUsername(),jmsg.getMessage());
logger.info("user {} : {}", session.getUsername(),jmsg.getMessage());

}

Expand Down

0 comments on commit 68a0089

Please sign in to comment.