Class: Vertx::WebSocketFrame

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb

Overview

A WebSocket frame that represents either text or binary data.

A WebSocket message is composed of one or more WebSocket frames.

If there is a just a single frame in the message then a single text or binary frame should be created with final = true.

If there are more than one frames in the message, then the first frame should be a text or binary frame with final = false, followed by one or more continuation frames. The last continuation frame should have final = true.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (::Vertx::WebSocketFrame) binary_frame(data = nil, isFinal = nil)

Create a binary WebSocket frame.

Parameters:

  • data (::Vertx::Buffer) (defaults to: nil)
    the data for the frame
  • isFinal (true, false) (defaults to: nil)
    true if it's the final frame in the WebSocket message

Returns:

Raises:

  • (ArgumentError)


44
45
46
47
48
49
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 44

def self.binary_frame(data=nil,isFinal=nil)
  if data.class.method_defined?(:j_del) && (isFinal.class == TrueClass || isFinal.class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:binaryFrame, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::boolean.java_class]).call(data.j_del,isFinal),::Vertx::WebSocketFrame)
  end
  raise ArgumentError, "Invalid arguments when calling binary_frame(#{data},#{isFinal})"
end

+ (::Vertx::WebSocketFrame) continuation_frame(data = nil, isFinal = nil)

Create a continuation frame

Parameters:

  • data (::Vertx::Buffer) (defaults to: nil)
    the data for the frame
  • isFinal (true, false) (defaults to: nil)
    true if it's the final frame in the WebSocket message

Returns:

Raises:

  • (ArgumentError)


82
83
84
85
86
87
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 82

def self.continuation_frame(data=nil,isFinal=nil)
  if data.class.method_defined?(:j_del) && (isFinal.class == TrueClass || isFinal.class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:continuationFrame, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::boolean.java_class]).call(data.j_del,isFinal),::Vertx::WebSocketFrame)
  end
  raise ArgumentError, "Invalid arguments when calling continuation_frame(#{data},#{isFinal})"
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

def self.j_class
  Java::IoVertxCoreHttp::WebSocketFrame.java_class
end

+ (::Vertx::WebSocketFrame) ping_frame(data = nil)

Create a ping WebSocket frame. Will be a final frame. There is no option for non final ping frames.

Parameters:

  • data (::Vertx::Buffer) (defaults to: nil)
    the bytes for the frame, may be at most 125 bytes

Returns:

Raises:

  • (ArgumentError)


63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 63

def self.ping_frame(data=nil)
  if data.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:pingFrame, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(data.j_del),::Vertx::WebSocketFrame)
  end
  raise ArgumentError, "Invalid arguments when calling ping_frame(#{data})"
end

+ (::Vertx::WebSocketFrame) pong_frame(data = nil)

Create a pong WebSocket frame. Will be a final frame. There is no option for non final pong frames.

Parameters:

  • data (::Vertx::Buffer) (defaults to: nil)
    the bytes for the frame, may be at most 125 bytes

Returns:

Raises:

  • (ArgumentError)


72
73
74
75
76
77
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 72

def self.pong_frame(data=nil)
  if data.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:pongFrame, [Java::IoVertxCoreBuffer::Buffer.java_class]).call(data.j_del),::Vertx::WebSocketFrame)
  end
  raise ArgumentError, "Invalid arguments when calling pong_frame(#{data})"
end

+ (::Vertx::WebSocketFrame) text_frame(str = nil, isFinal = nil)

Create a text WebSocket frame.

Parameters:

  • str (String) (defaults to: nil)
    the string for the frame
  • isFinal (true, false) (defaults to: nil)
    true if it's the final frame in the WebSocket message

Returns:

Raises:

  • (ArgumentError)


54
55
56
57
58
59
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 54

def self.text_frame(str=nil,isFinal=nil)
  if str.class == String && (isFinal.class == TrueClass || isFinal.class == FalseClass) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:textFrame, [Java::java.lang.String.java_class,Java::boolean.java_class]).call(str,isFinal),::Vertx::WebSocketFrame)
  end
  raise ArgumentError, "Invalid arguments when calling text_frame(#{str},#{isFinal})"
end

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (true, false) binary?

Returns true if it's a binary frame

Returns:

  • (true, false)
    true if it's a binary frame

Raises:

  • (ArgumentError)


96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 96

def binary?
  if !block_given?
    return @j_del.java_method(:isBinary, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling binary?()"
end

- (::Vertx::Buffer) binary_data

Returns the data of the frame

Returns:

Raises:

  • (ArgumentError)


127
128
129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 127

def binary_data
  if !block_given?
    if @cached_binary_data != nil
      return @cached_binary_data
    end
    return @cached_binary_data = ::Vertx::Util::Utils.safe_create(@j_del.java_method(:binaryData, []).call(),::Vertx::Buffer)
  end
  raise ArgumentError, "Invalid arguments when calling binary_data()"
end

- (true, false) close?

Returns true if it's close frame

Returns:

  • (true, false)
    true if it's close frame

Raises:

  • (ArgumentError)


110
111
112
113
114
115
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 110

def close?
  if !block_given?
    return @j_del.java_method(:isClose, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close?()"
end

- (String) close_reason

Returns string explaining close reason. Only use this for close frames

Returns:

  • (String)
    string explaining close reason. Only use this for close frames

Raises:

  • (ArgumentError)


151
152
153
154
155
156
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 151

def close_reason
  if !block_given?
    return @j_del.java_method(:closeReason, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close_reason()"
end

- (Fixnum) close_status_code

Returns status code of close frame. Only use this for close frames

Returns:

  • (Fixnum)
    status code of close frame. Only use this for close frames

Raises:

  • (ArgumentError)


144
145
146
147
148
149
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 144

def close_status_code
  if !block_given?
    return @j_del.java_method(:closeStatusCode, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling close_status_code()"
end

- (true, false) continuation?

Returns true if it's a continuation frame

Returns:

  • (true, false)
    true if it's a continuation frame

Raises:

  • (ArgumentError)


103
104
105
106
107
108
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 103

def continuation?
  if !block_given?
    return @j_del.java_method(:isContinuation, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling continuation?()"
end

- (true, false) final?

Returns true if this is the final frame.

Returns:

  • (true, false)
    true if this is the final frame.

Raises:

  • (ArgumentError)


137
138
139
140
141
142
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 137

def final?
  if !block_given?
    return @j_del.java_method(:isFinal, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling final?()"
end

- (true, false) text?

Returns true if it's a text frame

Returns:

  • (true, false)
    true if it's a text frame

Raises:

  • (ArgumentError)


89
90
91
92
93
94
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 89

def text?
  if !block_given?
    return @j_del.java_method(:isText, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling text?()"
end

- (String) text_data

Returns the content of this frame as a UTF-8 string and returns the converted string. Only use this for text frames.

Returns:

  • (String)
    the content of this frame as a UTF-8 string and returns the converted string. Only use this for text frames.

Raises:

  • (ArgumentError)


117
118
119
120
121
122
123
124
125
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/web_socket_frame.rb', line 117

def text_data
  if !block_given?
    if @cached_text_data != nil
      return @cached_text_data
    end
    return @cached_text_data = @j_del.java_method(:textData, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling text_data()"
end