Sha256: ed0a15ff8c0acd90289c7529dc6436d44b32b29a3145a86c5931a14c7fd06d6d
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
module DDE # Class encapsulates DDE Server with basic functionality (starting/stopping named service) class Server < App attr_reader :service # service(s) that this Server supports def start_service( name, init_flags=nil, &dde_callback ) try "Starting service #{name}", DDE::Errors::ServiceError do # Trying to start DDE if it was inactive error unless dde_active? || start_dde( init_flags, &dde_callback ) # Create DDE string for name (this creates handle that can be passed to DDEML functions) @service = DDE::DdeString.new(@id, name) # Register new DDE service, returns true/false success code error unless dde_name_service(@id, @service.handle, DNS_REGISTER) end end def stop_service try "Stopping active service", DDE::Errors::ServiceError do error "Either DDE or service not initialized" unless dde_active? && service_active? # Unregister DDE service, returns true/false success code error unless dde_name_service(@id, @service.handle, DNS_UNREGISTER); # Free string handle for service name error unless dde_free_string_handle(@id, @service.handle) # Clear handle if service successfuly stopped @service = nil end end def service_active? !!@service end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dde-0.2.9 | lib/dde/server.rb |
dde-0.2.8 | lib/dde/server.rb |
dde-0.2.2 | lib/dde/server.rb |