Class: Up::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/up/client.rb,
ext/up_ext/up_ext.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject (readonly)

instance vars are set by the server



12
13
14
# File 'lib/up/client.rb', line 12

def env
  @env
end

#handlerObject

instance vars are set by the server



12
13
14
# File 'lib/up/client.rb', line 12

def handler
  @handler
end

#protocolObject (readonly)

instance vars are set by the server



12
13
14
# File 'lib/up/client.rb', line 12

def protocol
  @protocol
end

#timeoutObject (readonly)

instance vars are set by the server



12
13
14
# File 'lib/up/client.rb', line 12

def timeout
  @timeout
end

Instance Method Details

#closeObject



399
400
401
402
# File 'ext/up_ext/up_ext.c', line 399

def close
  @open = false
  `#@ws?.close()`
end

#open?Boolean



20
21
22
# File 'lib/up/client.rb', line 20

def open?
  @open
end

#pendingObject



407
408
409
410
# File 'ext/up_ext/up_ext.c', line 407

def pending
  return -1 unless @open
  `#@ws?.getBufferedAmount()`
end

#publish(*args) ⇒ Object

fprintf(stderr, “read: %sn”, read_buf);



450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'ext/up_ext/up_ext.c', line 450

def publish(channel, message, engine = nil)
  res = false
  raise 'publish engine not supported' if engine
  %x{
    if (!message.$$is_string) {
      message = JSON.stringify(message);
    }
    res = #@server?.publish(channel, message);
    if (engine !== false && self.worker) {
      process.send({c: channel, m: message});
    }
  }
  res
end

#pubsub?Boolean



24
25
26
# File 'lib/up/client.rb', line 24

def pubsub?
  true
end

#subscribe(*args) ⇒ Object



491
492
493
494
# File 'ext/up_ext/up_ext.c', line 491

def subscribe(channel, is_pattern = false, &block)
  @sub_block = block
  `#@ws?.subscribe(channel)`
end

#unsubscribe(*args) ⇒ Object



519
520
521
# File 'ext/up_ext/up_ext.c', line 519

def unsubscribe(channel, is_pattern = false)
  `#@ws?.unsubscribe(channel)`
end

#write(rdata) ⇒ Object



505
506
507
# File 'ext/up_ext/up_ext.c', line 505

def write(data)
  `#@ws?.send(data, false)`
end