module Plezi::Base::Bridge

This module bridges between the Plezi Controller and the Iodine::Connection .

Constants

CLIENT_NAME
CONTROLLER_NAME

Public Instance Methods

controller(client) click to toggle source
# File lib/plezi/controller/bridge.rb, line 8
def controller client
  client.env[CONTROLLER_NAME]
end
on_close(client) click to toggle source

called when the client is closed (no longer available)

# File lib/plezi/controller/bridge.rb, line 32
def on_close client
   controller(client).on_close
end
on_drained(client) click to toggle source

called when all the previous calls to `client.write` have completed (the local buffer was drained and is now empty)

# File lib/plezi/controller/bridge.rb, line 37
def on_drained client
   controller(client).on_drained
end
on_message(client, data) click to toggle source

called when data is available

# File lib/plezi/controller/bridge.rb, line 23
def on_message client, data
   controller(client).on_message(data)
end
on_open(client) click to toggle source

called when the callback object is linked with a new client

# File lib/plezi/controller/bridge.rb, line 13
def on_open client
  c = controller(client)
  c.instance_variable_set(CLIENT_NAME, client)
  if client.protocol == :sse
    c.on_sse
  else
    c.on_open
  end
end
on_shutdown(client) click to toggle source

called when the server is shutting down, before closing the client (it's still possible to send messages to the client)

# File lib/plezi/controller/bridge.rb, line 28
def on_shutdown client
   controller(client).on_shutdown
end