Sha256: 7ac9fcfd502c0fe98b91b96a546265dc5371582987fd7bae508a9cfb371e07bd
Contents?: true
Size: 1011 Bytes
Versions: 22
Compression:
Stored size: 1011 Bytes
Contents
module Artoo module Api # The Artoo::Api::DeviceEventClient class is how a websocket client can subscribe # to event notifications for a specific device. # Example: ardrone nav data class DeviceEventClient include Celluloid include Celluloid::Notifications include Celluloid::Logger attr_reader :topic # Create new event client # @param [Socket] websocket # @param [String] topic def initialize(websocket, topic) @topic = topic info "Streaming #{@topic} to websocket..." @socket = websocket subscribe(@topic, :notify_event) end # Event notification # @param [String] topic # @param [Object] data def notify_event(topic, *data) # TODO: send which topic sent the notification @socket << data.last.to_s rescue Reel::SocketError, Errno::EPIPE info "Device event notification #{topic} websocket disconnected" terminate end end end end
Version data entries
22 entries across 22 versions & 1 rubygems