Class JsonConnection

    • Constructor Detail

      • JsonConnection

        public JsonConnection​(org.eclipse.jetty.websocket.api.Session connection)
      • JsonConnection

        public JsonConnection​(java.io.DataOutputStream output)
    • Method Detail

      • getObjectMapper

        @Nonnull
        public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        Get the ObjectMapper for this connection.
        Returns:
        the ObjectMapper
      • sendMessage

        public void sendMessage​(@Nonnull
                                com.fasterxml.jackson.databind.JsonNode message,
                                @Nonnull
                                JsonRequest request)
                         throws java.io.IOException
        Send a JsonNode to the instantiated connection.

        This method throws an IOException so the server or servlet holding the connection open can respond to the exception.

        If JsonServerPreferences.getValidateServerMessages() is true, a message is sent to the client that validation failed instead of the intended message.

        Overriding methods must ensure that message is only sent if validated.

        Parameters:
        message - the object or array to send as a message
        request - the JSON request
        Throws:
        java.io.IOException - if unable to send the message
      • sendMessage

        public void sendMessage​(@Nonnull
                                com.fasterxml.jackson.databind.JsonNode message,
                                int id)
                         throws java.io.IOException
        Send a JsonNode to the instantiated connection.

        This method throws an IOException so the server or servlet holding the connection open can respond to the exception.

        If JsonServerPreferences.getValidateServerMessages() is true, a message is sent to the client that validation failed instead of the intended message.

        Overriding methods must ensure that message is only sent if validated.

        Parameters:
        message - the object or array to send as a message
        id - the message id set by the client
        Throws:
        java.io.IOException - if unable to send the message
      • getVersion

        public java.lang.String getVersion()
      • setVersion

        public void setVersion​(java.lang.String version)