Sha256: 4b3f6bfab6e5ec7f411de6b9d8edea412a39c990660efbed368d6a19b1cfbbce

Contents?: true

Size: 553 Bytes

Versions: 1

Compression:

Stored size: 553 Bytes

Contents

class Myo::Band

  def initialize(socket)
    @socket = socket
  end

  def run
    EM.run do
      conn = EventMachine::WebSocketClient.connect(@socket)
      conn.callback do
        conn.send_msg "Hello!"
        conn.send_msg "done"
      end

      conn.errback do |e|
        puts "Got error: #{e}"
      end

      conn.stream do |msg|
        puts "<#{msg}>"
        if msg.data == "done"
          conn.close_connection
        end
      end

      conn.disconnect do
        puts "gone"
        EM::stop_event_loop
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
myo-ruby-wrapper-0.0.1 lib/myo/band.rb