class MaxCube::Messages::TCP::Parser
Extends {Messages::Parser} and {TCP::Handler} of routines connected to TCP
Cube messages parsing.
Constants
- MSG_TYPES
Known message types in the direction Cube -> client.
Public Instance Methods
parse_tcp_data(raw_data)
click to toggle source
Processes set of messages - raw data separated by +\r\n+. Calls {#check_tcp_data} and maps {#parse_tcp_msg} on each message. @param raw_data [String] raw data from a Cube @return [Array<Hash>] particular message contents
# File lib/maxcube/messages/tcp/parser.rb, line 26 def parse_tcp_data(raw_data) check_tcp_data(raw_data) raw_data.split("\r\n").map(&method(:parse_tcp_msg)) end
parse_tcp_msg(msg)
click to toggle source
Parses single message already without +\r\n+. Subsequently calls {#check_tcp_msg}, {#parse_msg_body} and {#check_tcp_hash}. @param msg [String] input message (without +\r\n+). @return [Hash] particular message contents separated into hash.
# File lib/maxcube/messages/tcp/parser.rb, line 37 def parse_tcp_msg(msg) check_tcp_msg(msg) body = msg.split(':')[1] || '' hash = { type: @msg_type } return hash unless parse_msg_body(body, hash, 'tcp') check_tcp_hash(hash) end