Sha256: 3882b2fc1dcae2306e787a331c69edb60111d70111e0d31ffec8dfb759a74472
Contents?: true
Size: 735 Bytes
Versions: 1
Compression:
Stored size: 735 Bytes
Contents
class ProtoSocket < FlashConnection def initialize(connection, message_callback) @connection = connection @message_callback = message_callback super() end def connection_completed token = @connection.current_user.communication_token send_json :operation => 'authenticate', :payload => {:type => 'web', :user_id => @connection.current_user.id, :token => token} periodic_ping end def receive_json(json) @message_callback.call(json) end def periodic_ping @ping ||= EventMachine.add_periodic_timer 30 do # log "sending ping" send_json :operation => 'ping' end end def unbind EventMachine::cancel_timer @ping end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protolink-0.2.8 | lib/protolink/proto_socket.rb |