Module: FayeServer
- Defined in:
- lib/faye-server/faye_server.rb
Instance Attribute Summary collapse
-
#messaging_server ⇒ Object
Returns the value of attribute messaging_server.
-
#messaging_server_options ⇒ Object
Returns the value of attribute messaging_server_options.
-
#messaging_server_port ⇒ Object
Returns the value of attribute messaging_server_port.
-
#messaging_server_thread ⇒ Object
Returns the value of attribute messaging_server_thread.
Instance Method Summary collapse
-
#publish(options = {}) ⇒ Object
Publish a message to a given channel Requres a :channel, and a :message.
-
#start(options = {}) ⇒ Object
Starts the Faye Server in a new thread.
-
#stop ⇒ Object
Stops Faye Server Somtimes Thin will return that it is wating on a client connection and you need to hit “ctrl-c”.
Instance Attribute Details
#messaging_server ⇒ Object
Returns the value of attribute messaging_server.
2 3 4 |
# File 'lib/faye-server/faye_server.rb', line 2 def messaging_server @messaging_server end |
#messaging_server_options ⇒ Object
Returns the value of attribute messaging_server_options.
2 3 4 |
# File 'lib/faye-server/faye_server.rb', line 2 def @messaging_server_options end |
#messaging_server_port ⇒ Object
Returns the value of attribute messaging_server_port.
2 3 4 |
# File 'lib/faye-server/faye_server.rb', line 2 def messaging_server_port @messaging_server_port end |
#messaging_server_thread ⇒ Object
Returns the value of attribute messaging_server_thread.
2 3 4 |
# File 'lib/faye-server/faye_server.rb', line 2 def messaging_server_thread @messaging_server_thread end |
Instance Method Details
#publish(options = {}) ⇒ Object
Publish a message to a given channel Requres a :channel, and a :message
27 28 29 30 31 |
# File 'lib/faye-server/faye_server.rb', line 27 def publish(={}) raise 'No Channel Provided' if ![:channel] raise 'No Message Provided' if ![:message] self.messaging_server.get_client.publish([:channel], [:message]) end |
#start(options = {}) ⇒ Object
Starts the Faye Server in a new thread
5 6 7 8 9 10 11 |
# File 'lib/faye-server/faye_server.rb', line 5 def start(={}) raise 'Already Running' if self.messaging_server and self.messaging_server_thread.status self.messaging_server_thread = Thread.new do self.messaging_server = Faye::RackAdapter.new(self.) self.messaging_server.listen(self.messaging_server_port) end end |
#stop ⇒ Object
Stops Faye Server Somtimes Thin will return that it is wating on a client connection and you need to hit “ctrl-c”
15 16 17 18 19 20 21 22 23 |
# File 'lib/faye-server/faye_server.rb', line 15 def stop raise 'Not Running' if !self.messaging_server or !self.messaging_server_thread.status self.messaging_server.stop if self.messaging_server_thread == 'dead' true else false end end |