Class: Vertx::WebSocketFrame

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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)


64
65
66
67
68
69
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 64

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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 37

def self.j_class
  Java::IoVertxCoreHttp::WebSocketFrame.java_class
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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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-stack/stack-docs/target/rb/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)


78
79
80
81
82
83
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 78

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)


102
103
104
105
106
107
108
109
110
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 102

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) continuation?

Returns true if it's a continuation frame

Returns:

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

Raises:

  • (ArgumentError)


85
86
87
88
89
90
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 85

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)


112
113
114
115
116
117
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 112

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)


71
72
73
74
75
76
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 71

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)


92
93
94
95
96
97
98
99
100
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/web_socket_frame.rb', line 92

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