Protocol::WebSocket SourceProtocolWebSocketTextFrame

class TextFrame

Represents a text frame that is sent or received by a WebSocket connection.

Definitions

def data?

Signature

returns Boolean

if the frame contains data.

Implementation

def data?
	true
end

def read_message(buffer)

Decode the binary buffer into a suitable text message.

Signature

parameter buffer String

The binary data to unpack.

Implementation

def read_message(buffer)
	buffer.force_encoding(Encoding::UTF_8)
	
	unless buffer.valid_encoding?
		raise ProtocolError, "invalid UTF-8 in text frame!"
	end
	
	return TextMessage.new(buffer)
end

def apply(connection)

Apply this frame to the specified connection.

Implementation

def apply(connection)
	connection.receive_text(self)
end