Class: VertxWeb::BridgeEvent

Inherits:
VertxBridgeCommon::BaseBridgeEvent show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb

Overview

Represents an event that occurs on the event bus bridge.

Please consult the documentation for a full explanation.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from VertxBridgeCommon::BaseBridgeEvent

#get_raw_message, #type

Methods inherited from Vertx::Promise

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

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 24

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

+ (Object) j_api_type



33
34
35
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 33

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



36
37
38
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 36

def self.j_class
  Java::IoVertxExtWebHandlerSockjs::BridgeEvent.java_class
end

+ (Object) unwrap(obj)



30
31
32
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 30

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

+ (Object) wrap(obj)



27
28
29
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 27

def @@j_api_type.wrap(obj)
  BridgeEvent.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


107
108
109
110
111
112
113
114
115
116
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 107

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


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

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

- (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)


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

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

- (::VertxWeb::SockJSSocket) socket

Get the SockJSSocket instance corresponding to the event

Returns:



88
89
90
91
92
93
94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/bridge_event.rb', line 88

def socket
  if !block_given?
    if @cached_socket != nil
      return @cached_socket
    end
    return @cached_socket = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:socket, []).call(),::VertxWeb::SockJSSocket)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling socket()"
  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


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

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