Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1926 Adding more commands to Forge and improve existing ones
  3. FORGE-2394

Being able to add methods to an existing Websocket Client or Server endpoints

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Unresolved
    • Icon: Major Major
    • 3.x Future
    • 2.17.0.Final
    • Java EE

      It would be good to be able to add methods to a Websocket Client or Server endpoint with the following command :

      websocket-add-method --named processOpen --method ON_OPEN
      

      This would add the processOpen method to the existing server endpoint :

      @ServerEndpoint("/abc")
      public class MyServerEndpoint {
      
          @OnOpen
          public void processOpen(Session session) {
          }
      

      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 :

          @OnOpen
          public void onOpen(Session session) {
          }
      
          @OnClose
          public void onClose(CloseReason closeReason) {
          }
      
          @OnError
          public void onError(Throwable t) {
          }
      

      The method signature of ON_MESSAGE can be customized. By default, the message can be of type String. So the following command :

      websocket-add-method --named processMsg --method ON_MESSAGE
      

      This would add the processMsg method of type String to the existing server endpoint :

      @ServerEndpoint("/abc")
      public class MyServerEndpoint {
      
          @OnMessage
          public void processMsg(String message, Session client) {
          }
      

      We could change the type of the message with :

      websocket-add-method --named processMsg --method ON_MESSAGE --type MyMessage
      

      This would add the processMsg method of type MyMessage :

      @ServerEndpoint("/abc")
      public class MyServerEndpoint {
      
          @OnMessage
          public void processMsg(MyMessage message, Session client) {
          }
      

              Unassigned Unassigned
              agoncal Antonio Goncalves (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: