resources/controller.rb in plezi-0.9.0 vs resources/controller.rb in plezi-0.9.1
- old
+ new
@@ -96,32 +96,33 @@
end
# called before the protocol is swithed from HTTP to WebSockets.
#
# this allows setting headers, cookies and other data (such as authentication)
- # prior to opening a WebSocket.
+ # prior to allowing a WebSocket to open.
#
# if the method returns false, the connection will be refused and the remaining routes will be attempted.
def pre_connect
- false
+ # false
+ true
end
# called immediately after a WebSocket connection has been established.
- # here we simply close the connection.
def on_connect
- response.close
- false
+ # response.close
+ # false
end
# called when new data is recieved
#
# data is a string that contains binary or UTF8 (message dependent) data.
#
# the demo content simply broadcasts the message.
def on_message data
# broadcast sends an asynchronous message to all sibling instances, but not to self.
broadcast :_print_out, data
+ response << "You said: #{data}"
end
# called when a disconnect packet has been recieved or the connection has been cut
# (ISN'T called after a disconnect message has been sent).
def on_disconnect
@@ -131,9 +132,9 @@
#
# methods that are protected and methods that start with an underscore are hidden from the router
# BUT, broadcasted methods must be public (or the broadcast will quietly fail)... so we have to use
# the _underscore for this method.
def _print_out data
- response << "Someone said #{data}"
+ response << "Someone said: #{data}"
end
end
\ No newline at end of file