Class: SkypeR::Service::Application
- Inherits:
-
Object
- Object
- SkypeR::Service::Application
- Defined in:
- lib/skyper/service.rb
Instance Method Summary collapse
-
#initialize(name, protocol_num = 5) ⇒ Application
constructor
A new instance of Application.
- #invoke(command, timeout = 60) ⇒ Object
- #parse(message) ⇒ Object
- #validate(command) ⇒ Object
Constructor Details
#initialize(name, protocol_num = 5) ⇒ Application
Returns a new instance of Application.
12 13 14 15 16 17 18 19 20 |
# File 'lib/skyper/service.rb', line 12 def initialize(name, protocol_num = 5) remote_bus = ::RBus.session_bus service_name = 'com.Skype.API' object_path = "/com/Skype" @api_object = remote_bus.get_object(service_name, object_path) @api_object.interface!(service_name) @application_name = name @invoked_commands = Hash.new end |
Instance Method Details
#invoke(command, timeout = 60) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/skyper/service.rb', line 22 def invoke(command, timeout = 60) begin ::Timeout.timeout(timeout) { authenticate @invoked_commands[command.command_id] = command.statement @api_object.Invoke("##{command.command_id} #{command.statement}") } rescue ::Timeout::Error puts "Connection timeout. Please try again." end end |
#parse(message) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/skyper/service.rb', line 35 def parse() case when CommandMessage command_parser = SkypeR::Parser::CommandStatement.new command_parser.parse(.statement) when ResponseMessage response_parser = SkypeR::Parser::ResponseCommandStatement.new response_parser.parse(.statement) else raise end end |
#validate(command) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/skyper/service.rb', line 48 def validate(command) case result = parse(command) when Yaparc::Result::OK true when Yaparc::Result::Fail false else raise end end |