Antonio Goncalves created FORGE-2394:
----------------------------------------
Summary: Being able to add methods to an existing Websocket Client or Server
endpoints
Key: FORGE-2394
URL:
https://issues.jboss.org/browse/FORGE-2394
Project: Forge
Issue Type: Sub-task
Components: Java EE
Affects Versions: 2.17.0.Final
Reporter: Antonio Goncalves
Fix For: 2.x Future
It would be good to be able to add methods to a Websocket Client or Server endpoint with
the following command :
{code}
websocket-add-method --named processOpen --method ON_OPEN
{code}
This would add the {{processOpen}} method to the existing server endpoint :
{code}
@ServerEndpoint("/abc")
public class MyServerEndpoint {
@OnOpen
public void processOpen(Session session) {
}
{code}
There are four method type :
* {{ON_OPEN}}
* {{ON_CLOSE}}
* {{ON_ERROR}}
* {{ON_MESSAGE}}
The method signature of {{ON_OPEN}}, {{ON_CLOSE}} and {{ON_ERROR}} are set and cannot be
changed :
{code}
@OnOpen
public void onOpen(Session session) {
}
@OnClose
public void onClose(CloseReason closeReason) {
}
@OnError
public void onError(Throwable t) {
}
{code}
The method signature of {{ON_MESSAGE}} can be customized. By default, the message can be
of type String. So the following command :
{code}
websocket-add-method --named processMsg --method ON_MESSAGE
{code}
This would add the {{processMsg}} method of type String to the existing server endpoint :
{code}
@ServerEndpoint("/abc")
public class MyServerEndpoint {
@OnMessage
public void processMsg(String message, Session client) {
}
{code}
We could change the type of the message with :
{code}
websocket-add-method --named processMsg --method ON_MESSAGE --type MyMessage
{code}
This would add the {{processMsg}} method of type {{MyMessage}} :
{code}
@ServerEndpoint("/abc")
public class MyServerEndpoint {
@OnMessage
public void processMsg(MyMessage message, Session client) {
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)