class SAPNW::RFC::Server



Public Instance Methods

accept(wait=120, callback=nil) click to toggle source

fire the accept loop taking optionally a wait time for each loop, and a global callback to be triggered after each loop/loop timeout. Callback - if supplied - must be a Proc object, that takes a simgle parameter, which is a hash of the system connection attributes.

# File lib/sapnwrfc/server.rb, line 118
                def accept(wait=120, callback=nil)
trap('INT', 'EXIT')
return @handle.accept_loop(wait, callback);
close() click to toggle source

terminate an established RFC connection. This will invalidate any currently in-scope FunctionDescriptors associated with this Connection.

# File lib/sapnwrfc/server.rb, line 141
        def close
SAP_LOGGER.debug("In #{self.class} close ...")
         return nil unless self.handle
SAP_LOGGER.debug("In #{self.class} handle: #{self.handle} ...")
res = self.handle.close()
              self.handle = nil
                        # XXX Should destroy all cached functions and structures and types tied to handle ?
              return true
connection_attributes() click to toggle source

Returns a Hash of the connections attributes of this server connection.

# File lib/sapnwrfc/server.rb, line 134
       def connection_attributes
SAP_LOGGER.debug("In #{self.class} connection_attributes ...")
return @attributes = self.handle.connection_attributes()
installFunction(*args) click to toggle source

installs a SAPNW::RFC::FunctionDescriptor object, and optionally associates this with a particular SysId.

# File lib/sapnwrfc/server.rb, line 80
  def installFunction(*args)
                  args = args.first if args.class == Array and args.first.class == Hash
                        case args
                          when Hash
                            raise "Must pass an instance of SAPNW::RFC::FunctionDescriptor to installFunction()\n" unless args.has_key?(:descriptor) and args[:descriptor].class == SAPNW::RFC::FunctionDescriptor
                                        func = args[:descriptor]
                                        sysid = args.has_key?(:sysid) ? args[:sysid] : ""
                                when Array
                            raise "Must pass an instance of SAPNW::RFC::FunctionDescriptor to installFunction()\n" unless args.first.class == SAPNW::RFC::FunctionDescriptor 
                                        func = args.first
                                        sysid = args.length > 1 ? args[1] : ""
                            raise "Must pass an instance of SAPNW::RFC::FunctionDescriptor to installFunction()\n"
#$stderr.print "sysid: #{sysid}\n"
                        res = func.install(sysid)
                        @functions[] = func
                        return res
process(wait=120) click to toggle source

similar to the accept() loop only that it does a single RfcListenAndDispatch() on the SAPNW::RFC::Server connection handle. The result is the RFC return code as per the SAPNW::RFC::RFC_* return code constants. process() optionally takes asingle parameter which is the wait-time.

# File lib/sapnwrfc/server.rb, line 128
                def process(wait=120)
trap('INT', 'EXIT')
return @handle.process_loop(wait);

Public Class Methods

handler(callback=nil,attributes=nil) click to toggle source
# File lib/sapnwrfc/server.rb, line 100
                def self.handler(callback=nil,attributes=nil)
                  return if callback == nil
rescue SAPNW::RFC::ServerException => e
  #$stderr.print "ServerException => #{e.error.inspect}\n"
  return e
rescue StandardError => e
  #$stderr.print "StandardError => #{e.inspect}/#{e.message}\n"
  return{'code' => 3, 'key' => 'RUBY_RUNTIME', 'message' => e.message})
new(args = nil) click to toggle source
# File lib/sapnwrfc/server.rb, line 61
  def initialize(args = nil)
                @connection_parameters = []
case args
                 when nil
                 when Hash
                   args.each_pair { |key, val|
                     @connection_parameters << { 'name' => key.to_s, 'value' => val.to_s }
                         raise "Wrong parameters for Server Connection - must pass a Hash\n"
SAP_LOGGER.debug("In #{self.class} initialize: #{@connection_parameters.inspect} ...")
                        @functions = {}
                        @attributes = nil
            @handle =