Class: Secure::SimpleConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/secure_con.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, c, localHost, localPort) ⇒ SimpleConnection

Returns a new instance of SimpleConnection.



210
211
212
213
214
# File 'lib/appswarm/secure_con.rb', line 210

def initialize(server,c,localHost,localPort)
  @c=c
  @server=server
  @c.send(Call.new(:hi,"hi",{:port=>localPort,:host=>localHost},true))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/appswarm/secure_con.rb', line 215

def method_missing(name,*args)
  if @server.remote_sync_func?(name)
    tx=@server.getTxId(self)
    call=Call.new(:call,name,args,tx)
    #puts "simplecon: sending #{call.inspect}"
    @c.send(call)
    # wait for @server to get return
    #puts "WAIT FOR RETURN OF #{name} #{args.inspect} in tx #{tx}"
    @server.getReturn(tx,self)
  elsif @server.remote_func?(name)
    call=Call.new(:call,name,args,nil)
    pp "CALL",call
    @c.send(call)
  else
    super
  end
end

Instance Attribute Details

#remoteHostObject



232
233
234
235
# File 'lib/appswarm/secure_con.rb', line 232

def remoteHost
  return @remoteHost if @remoteHost
  @c.remoteHost
end

#remotePortObject



236
237
238
239
# File 'lib/appswarm/secure_con.rb', line 236

def remotePort
  return @remotePort if @remotePort
  @c.remotePort
end

Instance Method Details

#connectionObject



245
246
247
# File 'lib/appswarm/secure_con.rb', line 245

def connection
  @c
end

#disconnectObject



241
242
243
# File 'lib/appswarm/secure_con.rb', line 241

def disconnect
  @c.disconnect
end