Sha256: 4b5d641cbf76511725e7a9575cfb597036d92e29fd66949fc34a63b4d2586fa8
Contents?: true
Size: 920 Bytes
Versions: 2
Compression:
Stored size: 920 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 puts "DISCONNECTED" EventMachine::cancel_timer @ping EventMachine::add_timer(30) { EventMachine.connect URI.parse(@connection.class.base_uri).host, 5000, ProtoSocket, @connection, @message_callback } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
protolink-0.2.10 | lib/protolink/proto_socket.rb |
protolink-0.2.9 | lib/protolink/proto_socket.rb |