xviz/docs/api-reference/server/xviz-websocket-sender.md
Timothy Wojtaszek a8cfc2bc29
Change specification enumerations to ALLCAPS (#477)
Follow the convention that constant enumerated values should be in ALLCAPS. This is a spec change for XVIZ, but retains compatibility with lowercase by forcing a case conversion at the appropriate places within the modules.

Spec change locations:
declarative ui properties
- component type
- layout
- interactions

xviz message
- type
  - xviz/start
    - session_type
    - message_format
    - log
  - xviz/metadata
    - stream metadata
      - category
      - scalar type, for time_series & variables
      - primitive type, for time_series & variables 
      - annotation_type, for annotations
    - stream style
      - text_anchor
      - text_baseline
  - xviz/state_update
    - update_type
  - xviz/reconfigure
    - update_type
2019-06-07 18:42:09 -04:00

1.4 KiB

XVIZWebSocketSender

XVIZWebSocketSender is a middleware component that will send the XVIZ message through a websocket.

It will ensure that the data is properly formatted for sending over a websocket and convert the data if necessary.

Example

  // In the context of an XVIZSession class

  this.middleware = new XVIZServerMiddlewareStack();

  const stack = [
    new XVIZProviderRequestHandler(this.context, this.provider, this.middleware, this.options),
    new XVIZWebsocketSender(this.context, this.socket, this.options)
  ];
  this.middleware.set(stack);

Constructor

XVIZWebSocketSender(context, socket, options)

Parameters:

  • context (XVIZSessionContext) - Shared session context to store data
  • socket (Object) - Websocket for the session
  • options (Object) - options object
    • compress (Boolean) - Choice to apply perMessageDeflate if the message wire format is TEXT
    • format (XVIZ_FORMAT) - Format of the XVIZ data to send to the client
    • logger (Object) - Logger object passed through the system
      • log (Function) - Function that will always display the message
      • error (Function) - Function for error level messages
      • warn (Function) - Function for warning level messages
      • info (Function) - Function for info level messages
      • verbose (Function) - Function for verbose level messages