Class: Hop::WssBearer::SocketLease

Inherits:
Object
  • Object
show all
Defined in:
lib/hop/wss_bearer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(admission, sock) ⇒ SocketLease

Returns a new instance of SocketLease.



217
218
219
220
221
222
# File 'lib/hop/wss_bearer.rb', line 217

def initialize(admission, sock)
  @admission = admission
  @sock = sock
  @lock = Mutex.new
  @released = false
end

Instance Attribute Details

#sockObject (readonly)

Returns the value of attribute sock.



215
216
217
# File 'lib/hop/wss_bearer.rb', line 215

def sock
  @sock
end

Instance Method Details

#closeObject



238
# File 'lib/hop/wss_bearer.rb', line 238

def close = (@sock.close rescue nil)

#releaseObject



229
230
231
232
233
234
235
236
# File 'lib/hop/wss_bearer.rb', line 229

def release
  @lock.synchronize do
    return if @released

    @released = true
    @admission.release(self)
  end
end

#replace(sock) ⇒ Object



224
225
226
227
# File 'lib/hop/wss_bearer.rb', line 224

def replace(sock)
  @sock = sock
  @admission.replace(self, sock)
end