Class FunctionMessage

java.lang.Object
com.jbstrap.core.websocket.messages.BaseMessage
com.jbstrap.core.websocket.messages.FunctionMessage
All Implemented Interfaces:
MessageWithReturnValue

public class FunctionMessage extends BaseMessage implements MessageWithReturnValue
Since:
4.0
Author:
JBStrap
  • Constructor Details

    • FunctionMessage

      public FunctionMessage()
      Creates a function message type message
  • Method Details

    • setFunctionName

      public final FunctionMessage setFunctionName(String functionName)
      Sets the JavaScript function name, that will be called.
      Parameters:
      functionName - The name of the JavaScript that will be called
      Returns:
      The Function call type message
    • getFunctionName

      public final String getFunctionName()
      Gets the JavaScript function name, that will be called.
      Returns:
      The name of the JavaScript that will be called
    • addParam

      public final FunctionMessage addParam(Object value)
      Adds a parameter
      Parameters:
      value - The parameter value
      Returns:
      The function call type message
    • addParams

      public final FunctionMessage addParams(Object... values)
      Adds multiple parameters to the message
      Parameters:
      values - The parameter values
      Returns:
      The function call type message
    • getParams

      public final List<Object> getParams()
      Gets the previously assigned parameters in a list.
      Returns:
      The list of the assigned parameters. If none were assigned, the list will be empty.
    • setTimeout

      public final FunctionMessage setTimeout(long timeout)
      Sets the timeout for the reply message.
      Parameters:
      timeout - The amount of time for waiting for the reply
      Returns:
      The function call type message
    • getTimeout

      public final long getTimeout()
      Gets the timeout amount
      Returns:
      The timeout amount
    • getParam

      public final <T> T getParam(int index)
      Gets the value of the parameter, that is specified by its index.
      Parameters:
      index - The index of the parameter
      Returns:
      The parameter value, or null, if not found