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



383
384
385
386
# File 'ext/up_ext/up_ext.c', line 383

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

#open?Boolean



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

def open?
  @open
end

#pendingObject



391
392
393
394
# File 'ext/up_ext/up_ext.c', line 391

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

#publish(*args) ⇒ Object

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



434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'ext/up_ext/up_ext.c', line 434

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



475
476
477
478
# File 'ext/up_ext/up_ext.c', line 475

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

#unsubscribe(*args) ⇒ Object



503
504
505
# File 'ext/up_ext/up_ext.c', line 503

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

#write(rdata) ⇒ Object



489
490
491
# File 'ext/up_ext/up_ext.c', line 489

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