Module: Juggernaut
- Defined in:
- lib/juggernaut.rb,
lib/juggernaut/client.rb,
lib/juggernaut/miscel.rb,
lib/juggernaut/runner.rb,
lib/juggernaut/server.rb,
lib/juggernaut/message.rb
Defined Under Namespace
Modules: Miscel
Classes: Client, JuggernautError, Message, Runner, Server
Constant Summary
collapse
- VERSION =
'0.5.8'
- DEFAULT_CONFIG_FILE =
" # ======================\n # Juggernaut Options\n # ======================\n\n # === Subscription authentication ===\n # Leave all subscription options uncommented to allow anyone to subscribe.\n\n # If specified, subscription_url is called everytime a client subscribes.\n # Parameters passed are: session_id, client_id and an array of channels.\n # \n # The server should check that the session_id matches up to the client_id\n # and that the client is allowed to access the specified channels.\n # \n # If a status code other than 200 is encountered, the subscription_request fails\n # and the client is disconnected.\n # \n # :subscription_url: http://localhost:3000/sessions/juggernaut_subscription\n\n # === Broadcast and query authentication ===\n # Leave all broadcast/query options uncommented to allow anyone to broadcast/query.\n # \n # Broadcast authentication in a production environment is very importantant since broadcasters\n # can execute JavaScript on subscribed clients, leaving you vulnerable to cross site scripting\n # attacks if broadcasters aren't authenticated. \n\n # 1) Via IP address\n # \n # If specified, if a client has an ip that is specified in allowed_ips, than it is automatically\n # authenticated, even if a secret_key isn't provided. \n # \n # This is the recommended method for broadcast authentication.\n #\n :allowed_ips: \n - 127.0.0.1\n # - 192.168.0.1\n\n # 2) Via HTTP request\n # \n # If specified, if a client attempts a broadcast/query, without a secret_key or using an IP\n # no included in allowed_ips, then broadcast_query_login_url will be called.\n # Parameters passed, if given, are: session_id, client_id, channels and type.\n # \n # The server should check that the session_id matches up to the client id, and the client\n # is allowed to perform that particular type of broadcast/query.\n # \n # If a status code other than 200 is encountered, the broadcast_query_login_url fails\n # and the client is disconnected.\n # \n # :broadcast_query_login_url: http://localhost:3000/sessions/juggernaut_broadcast\n\n # 3) Via shared secret key\n # \n # This secret key must be sent with any query/broadcast commands. \n # It must be the same as the one in the Rails config file.\n # \n # You shouldn't authenticate broadcasts from subscribed clients using this method\n # since the secret_key will be easily visible in the page (and not so secret any more)!\n # \n # :secret_key: your_secret_key_here\n\n # == Subscription Logout ==\n\n # If specified, logout_connection_url is called everytime a specific connection from a subscribed client disconnects. \n # Parameters passed are session_id, client_id and an array of channels specific to that connection.\n # \n # :logout_connection_url: http://localhost:3000/sessions/juggernaut_connection_logout\n\n # Logout url is called when all connections from a subscribed client are closed.\n # Parameters passed are session_id and client_id.\n # \n # :logout_url: http://localhost:3000/sessions/juggernaut_logout\n\n # === Miscellaneous ===\n\n # timeout defaults to 10. A timeout is the time between when a client closes a connection\n # and a logout_request or logout_connection_request is made. The reason for this is that a client\n # may only temporarily be disconnected, and may attempt a reconnect very soon.\n # \n # :timeout: 10\n\n # store_messages defaults to false. If this option is true, messages send to connections will be stored. \n # This is useful since a client can then receive broadcasted message that it has missed (perhaps it was disconnected).\n #\n # :store_messages: false\n\n # === Server ===\n\n # Host defaults to \"0.0.0.0\". You shouldn't need to change this.\n # :host: 0.0.0.0\n\n # Port is mandatory\n :port: 5001\n \n # Defaults to value of :port. If you are doing port forwarding you'll need to configure this to the same \n # value as :public_port in the juggernaut_hosts.yml file\n # :public_port: 5001\n\n"
- @@options =
{}
Class Method Summary
collapse
Class Method Details
.config_path ⇒ Object
146
147
148
|
# File 'lib/juggernaut.rb', line 146
def config_path
options[:config_path] || File.join(%w( / var run juggernaut.yml ))
end
|
.log_path ⇒ Object
138
139
140
|
# File 'lib/juggernaut.rb', line 138
def log_path
options[:log_path] || File.join(%w( / var run juggernaut.log ))
end
|
.logger ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/juggernaut.rb', line 124
def logger
return @@logger if defined?(@@logger) && !@@logger.nil?
FileUtils.mkdir_p(File.dirname(log_path))
@@logger = Logger.new(log_path)
@@logger.level = Logger::INFO if options[:debug] == false
@@logger
rescue
@@logger = Logger.new(STDOUT)
end
|
.logger=(logger) ⇒ Object
134
135
136
|
# File 'lib/juggernaut.rb', line 134
def logger=(logger)
@@logger = logger
end
|
.options ⇒ Object
116
117
118
|
# File 'lib/juggernaut.rb', line 116
def options
@@options
end
|
.options=(val) ⇒ Object
120
121
122
|
# File 'lib/juggernaut.rb', line 120
def options=(val)
@@options = val
end
|
.pid_path ⇒ Object
142
143
144
|
# File 'lib/juggernaut.rb', line 142
def pid_path
options[:pid_path] || File.join(%w( / var run ), "juggernaut.#{options[:port]}.pid" )
end
|