Class: TIPCEvent

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

Overview

Represents a TIPC event message.

TIPC event messages are returned by the TIPC topology server when subscribed to events occur.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, found_lower, found_upper, port, subscr) ⇒ TIPCEvent

Create a new TIPCEvent instance.

Parameters

* event       - 32-bit event type, may be either TIPC_PUBLISHED, TIPC_WITHDRAWN,
                or TIPC_SUBSCR_TIMEOUT
* found_lower - 32-bit lower bound of the port name sequence that overlaps
                the name sequence specified by the subscription
* found_upper - 32-bit upper bound of the port name sequence that overlaps
                the name sequence specified by the subscription
* port        - an instance of TIPCPortId that represents the port ID of the
                associated port
* subscr      - an instance of TIPCSubscr that represents the subscription
                request associated with the event


360
361
362
363
364
365
366
# File 'lib/tipcsocket.rb', line 360

def initialize(event, found_lower, found_upper, port, subscr)
  @event       = event
  @found_lower = found_lower
  @found_upper = found_upper
  @port        = port
  @subscr      = subscr
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



345
346
347
# File 'lib/tipcsocket.rb', line 345

def event
  @event
end

#found_lowerObject

Returns the value of attribute found_lower.



345
346
347
# File 'lib/tipcsocket.rb', line 345

def found_lower
  @found_lower
end

#found_upperObject

Returns the value of attribute found_upper.



345
346
347
# File 'lib/tipcsocket.rb', line 345

def found_upper
  @found_upper
end

#portObject

Returns the value of attribute port.



345
346
347
# File 'lib/tipcsocket.rb', line 345

def port
  @port
end

#subscrObject

Returns the value of attribute subscr.



345
346
347
# File 'lib/tipcsocket.rb', line 345

def subscr
  @subscr
end

Class Method Details

.unpack(bytes) ⇒ Object

Create a new TIPCEvent instance from a 48 byte binary string containing a TIPC event.

Parameters

* bytes - 48 byte string containing TIPC address


391
392
393
394
395
# File 'lib/tipcsocket.rb', line 391

def self.unpack(bytes)
  data = bytes.unpack("L3a8a28")
  self.new(data[0], data[1], data[2], TIPCPortId.unpack(data[3]),
           TIPCSubscr.unpack(data[4]))
end

Instance Method Details

#packObject

Pack an instance of a TIPCEvent.

Produces an 48 byte string with the following format:

* event       - uint32 = 4
* found_lower - uint32 = 4
* found_upper - uint32 = 4
* port_id              = 8
* subscr               = 28


376
377
378
379
380
381
382
383
384
# File 'lib/tipcsocket.rb', line 376

def pack
  [
    self.event,
    self.found_lower,
    self.found_upper,
    port.pack,
    subscr.pack
  ].pack("L3a8a28")
end