module Blade::Server

Constants

WEBSOCKET_PATH

Public Instance Methods

client() click to toggle source
# File lib/blade/server.rb, line 24
def client
  @client ||= Faye::Client.new(websocket_url)
end
host() click to toggle source
# File lib/blade/server.rb, line 16
def host
  Thin::Server::DEFAULT_HOST
end
publish(channel, message) click to toggle source
# File lib/blade/server.rb, line 34
def publish(channel, message)
  client.publish(channel, message)
end
start() click to toggle source
# File lib/blade/server.rb, line 10
def start
  Faye::WebSocket.load_adapter("thin")
  Thin::Logging.silent = true
  Thin::Server.start(host, Blade.config.port, app, signals: false)
end
subscribe(channel) { |with_indifferent_access| ... } click to toggle source
# File lib/blade/server.rb, line 28
def subscribe(channel)
  client.subscribe(channel) do |message|
    yield message.with_indifferent_access
  end
end
websocket_url(path = "") click to toggle source
# File lib/blade/server.rb, line 20
def websocket_url(path = "")
  Blade.url(WEBSOCKET_PATH + path)
end

Private Instance Methods

app() click to toggle source
# File lib/blade/server.rb, line 39
def app
  Rack::Builder.app do
    use Rack::ShowExceptions
    run Blade::RackAdapter.new
  end
end