Class: Vertx::WebSocketFrame

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/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.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

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


28
29
30
31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 28

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::WebSocketFrame.new(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:binaryFrame, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::boolean.java_class]).call(data.j_del,isFinal))
  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)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 48

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::WebSocketFrame.new(Java::IoVertxCoreHttp::WebSocketFrame.java_method(:continuationFrame, [Java::IoVertxCoreBuffer::Buffer.java_class,Java::boolean.java_class]).call(data.j_del,isFinal))
  end
  raise ArgumentError, "Invalid arguments when calling continuation_frame(data,isFinal)"
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)


38
39
40
41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 38

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

Instance Method Details

- (true, false) binary?

@return true if it's a binary frame

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


64
65
66
67
68
69
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 64

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

@return the data of the frame

Returns:

Raises:

  • (ArgumentError)


92
93
94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 92

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

- (true, false) continuation?

@return true if it's a continuation frame

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


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

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

- (true, false) final?

@return true if this is the final frame.

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


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

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

- (true, false) text?

@return true if it's a text frame

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


56
57
58
59
60
61
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 56

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

- (String) text_data

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

Returns:

  • (String)

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
89
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/web_socket_frame.rb', line 81

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