Class: Mfp::Proto::Hello
- Inherits:
-
Object
- Object
- Mfp::Proto::Hello
- Defined in:
- lib/mfp/proto/hello.rb
Overview
Hello is the payload of a MessageKindHello frame. It must be the first frame sent by the client on every connection. The server responds with either a HelloResponse or an Error.
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#capabilities ⇒ Object
Returns the value of attribute capabilities.
-
#host ⇒ Object
Returns the value of attribute host.
-
#version_major ⇒ Object
Returns the value of attribute version_major.
-
#version_minor ⇒ Object
Returns the value of attribute version_minor.
Class Method Summary collapse
Instance Method Summary collapse
- #encode(stream_id) ⇒ Object
-
#initialize(version_major:, version_minor:, capabilities: 0, application: "", host: "") ⇒ Hello
constructor
A new instance of Hello.
Constructor Details
#initialize(version_major:, version_minor:, capabilities: 0, application: "", host: "") ⇒ Hello
Returns a new instance of Hello.
11 12 13 14 15 16 17 |
# File 'lib/mfp/proto/hello.rb', line 11 def initialize(version_major:, version_minor:, capabilities: 0, application: "", host: "") @version_major = version_major @version_minor = version_minor @capabilities = capabilities @application = application @host = host end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
9 10 11 |
# File 'lib/mfp/proto/hello.rb', line 9 def application @application end |
#capabilities ⇒ Object
Returns the value of attribute capabilities.
9 10 11 |
# File 'lib/mfp/proto/hello.rb', line 9 def capabilities @capabilities end |
#host ⇒ Object
Returns the value of attribute host.
9 10 11 |
# File 'lib/mfp/proto/hello.rb', line 9 def host @host end |
#version_major ⇒ Object
Returns the value of attribute version_major.
9 10 11 |
# File 'lib/mfp/proto/hello.rb', line 9 def version_major @version_major end |
#version_minor ⇒ Object
Returns the value of attribute version_minor.
9 10 11 |
# File 'lib/mfp/proto/hello.rb', line 9 def version_minor @version_minor end |
Class Method Details
.read(fr) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mfp/proto/hello.rb', line 36 def self.read(fr) raise ParserError.new(ErrorKind::FRAME_SIZE_ERROR) if fr.length < 8 r = Reader.new(StringIO.new(fr.payload)) version_major = r.read_byte version_minor = r.read_byte capabilities = r.read_u16 application = r.read_u16_string host = r.read_u16_string new(version_major:, version_minor:, capabilities:, application:, host:) end |
Instance Method Details
#encode(stream_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mfp/proto/hello.rb', line 19 def encode(stream_id) buf = Writer.new buf.write_u8(@version_major) buf.write_u8(@version_minor) buf.write_u16(@capabilities) buf.write_u16_string(@application) buf.write_u16_string(@host) Frame.new( stream_id:, kind: MessageKind::HELLO, flags: 0, length: buf.length, payload: buf.string, ) end |