module Gamefic::Mud::Adapter::Websocket

The WebSocket client adapter module.

Public Instance Methods

send_raw(data) click to toggle source

@param data [String] @return [void]

# File lib/gamefic-mud/adapter/websocket.rb, line 22
def send_raw data
  # Convert raw text to a hash with a `messages` key so the WebSocket
  # client can rely on a single standard for incoming data.
  update({messages: data})
end
update(output) click to toggle source

@param output [Hash] @return [void]

# File lib/gamefic-mud/adapter/websocket.rb, line 13
def update output
  # Websocket connections are assumed to be rich clients. Send them
  # the entire output hash and let them determine how to render the
  # data.
  send output.to_json
end