Class: Munge::Extra::Livereload::Messaging
- Inherits:
-
Object
- Object
- Munge::Extra::Livereload::Messaging
- Defined in:
- lib/munge/extra/livereload/messaging.rb
Instance Method Summary collapse
Instance Method Details
#hello ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/munge/extra/livereload/messaging.rb', line 5 def hello JSON.generate( command: "hello", protocols: [the_protocol], serverName: "munge-livereload" ) end |
#reload(changed_file) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/munge/extra/livereload/messaging.rb', line 13 def reload(changed_file) JSON.generate( command: "reload", path: changed_file, liveCSS: "false" ) end |
#valid_handshake?(socket_data) ⇒ Boolean
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/munge/extra/livereload/messaging.rb', line 21 def valid_handshake?(socket_data) client_handshake = JSON.parse(socket_data) return false if client_handshake["command"] != "hello" return false if !client_handshake["protocols"].include?(the_protocol) true rescue false end |