I don't know how to send a message to the @ServerEndpoint. I want to send a message from different project to the project which contains @ServerEndpoint. @ServerEndpoint code below...
@ServerEndpoint("/posluzitelj")
@Stateless
public class Posluzitelj {
static Queue<Session> queue = new ConcurrentLinkedQueue<>();
public static void send(String message) {
}
@OnMessage
public void onMessage(String message) {
}
@OnOpen
public void openConnection(Session session) {
queue.add(session);
}
@OnClose
public void closedConnection(Session session) {
queue.remove(session);
}
@OnError
public void error(Session session, Throwable t) {
queue.remove(session);
}
}
So, I wanna trigger onMessage function via another project class. How can I do that? Also, I do not want to use javascript! I wanna make communication with java language.
The problem is solved with @ClientEndpoint annotation. Link: ServerEndpoint