Class: VertxBridgeCommon::BaseBridgeEvent

Inherits:
Vertx::Promise show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb

Overview

Represents an event that occurs on the event bus bridge.

Please consult the documentation for a full explanation.

Direct Known Subclasses

VertxTcpEventbusBridge::BridgeEvent, VertxWeb::BridgeEvent

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Vertx::Promise

#fail, failed_promise, promise, succeeded_promise, #try_fail?

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 23

def @@j_api_type.accept?(obj)
  obj.class == BaseBridgeEvent
end

+ (Object) j_api_type



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 32

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 35

def self.j_class
  Java::IoVertxExtBridge::BaseBridgeEvent.java_class
end

+ (Object) unwrap(obj)



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 29

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 26

def @@j_api_type.wrap(obj)
  BaseBridgeEvent.new(obj)
end

Instance Method Details

- (void) complete(result)

This method returns an undefined value.

Set the result. Any handler will be called, if there is one, and the promise will be marked as completed.

Any handler set on the associated promise will be called.

Parameters:

  • result (true, false)
    the result


120
121
122
123
124
125
126
127
128
129
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 120

def complete(*args)
  if (args[0].class == TrueClass || args[0].class == FalseClass) && !block_given?
    return @j_del.java_method(:complete, [Java::JavaLang::Boolean.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling complete(#{args[0]})"
  end
end

- (::Vertx::Future) future

Returns the associated with this promise, it can be used to be aware of the promise completion

Returns:

  • (::Vertx::Future)
    the associated with this promise, it can be used to be aware of the promise completion


40
41
42
43
44
45
46
47
48
49
50
51
52
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 40

def future
  if !block_given?
    if @cached_future != nil
      return @cached_future
    end
    return @cached_future = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:future, []).call(),::Vertx::Future, nil)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling future()"
  end
end

- (Hash{String => Object}) getRawMessage

Get the raw JSON message for the event. This will be null for SOCKET_CREATED or SOCKET_CLOSED events as there is no message involved. If the returned message is modified, #set_raw_message should be called with the new message.

Returns:

  • (Hash{String => Object})
    the raw JSON message for the event


74
75
76
77
78
79
80
81
82
83
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 74

def get_raw_message
  if !block_given?
    return @j_del.java_method(:getRawMessage, []).call() != nil ? JSON.parse(@j_del.java_method(:getRawMessage, []).call().encode) : nil
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_message()"
  end
end

- (self) setRawMessage(message)

Get the raw JSON message for the event. This will be null for SOCKET_CREATED or SOCKET_CLOSED events as there is no message involved.

Parameters:

  • message (Hash{String => Object})
    the raw message

Returns:

  • (self)


58
59
60
61
62
63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 58

def set_raw_message(*args)
  if args[0].class == Hash && !block_given?
    @j_del.java_method(:setRawMessage, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(args[0]))
    return self
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_raw_message(#{args[0]})"
  end
end

- (true, false) tryComplete(result)

Like Vertx::Promise#complete but returns false when the promise is already completed instead of throwing an IllegalStateException, it returns true otherwise.

Parameters:

  • result (true, false)
    the result

Returns:

  • (true, false)
    false when the future is already completed


89
90
91
92
93
94
95
96
97
98
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 89

def try_complete?(*args)
  if (args[0].class == TrueClass || args[0].class == FalseClass) && !block_given?
    return @j_del.java_method(:tryComplete, [Java::JavaLang::Boolean.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling try_complete?(#{args[0]})"
  end
end

- (:SOCKET_CREATED, ...) type

Returns the type of the event

Returns:

  • (:SOCKET_CREATED, :SOCKET_CLOSED, :SOCKET_IDLE, :SOCKET_PING, :SEND, :PUBLISH, :RECEIVE, :REGISTER, :REGISTERED, :UNREGISTER)
    the type of the event


101
102
103
104
105
106
107
108
109
110
111
112
113
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-bridge-common/base_bridge_event.rb', line 101

def type
  if !block_given?
    if @cached_type != nil
      return @cached_type
    end
    return @cached_type = @j_del.java_method(:type, []).call().name.intern
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling type()"
  end
end