Module: Plum::ConnectionUtils

Included in:
Connection
Defined in:
lib/plum/connection_utils.rb

Instance Method Summary collapse

Instance Method Details

#goaway(error_type = :no_error) ⇒ Object

Sends GOAWAY frame to the peer and closes the connection.

Parameters:

  • error_type (Symbol) (defaults to: :no_error)

    The error type to be contained in the GOAWAY frame.


22
23
24
25
# File 'lib/plum/connection_utils.rb', line 22

def goaway(error_type = :no_error)
  last_id = @max_stream_id
  send_immediately Frame.goaway(last_id, error_type)
end

#ping(data = "plum\x00\x00\x00\x00") ⇒ Object

Sends a PING frame to the peer.

Parameters:

  • data (String) (defaults to: "plum\x00\x00\x00\x00")

    Must be 8 octets.

Raises:

  • (ArgumentError)

    If the data is not 8 octets.


16
17
18
# File 'lib/plum/connection_utils.rb', line 16

def ping(data = "plum\x00\x00\x00\x00")
  send_immediately Frame.ping(data)
end

#push_enabled?Boolean

Returns whether peer enables server push or not

Returns:

  • (Boolean)

28
29
30
# File 'lib/plum/connection_utils.rb', line 28

def push_enabled?
  @remote_settings[:enable_push] == 1
end

#settings(**kwargs) ⇒ Object

Sends local settings to the peer.

Parameters:

  • kwargs (Hash<Symbol, Integer>)

8
9
10
11
# File 'lib/plum/connection_utils.rb', line 8

def settings(**kwargs)
  send_immediately Frame.settings(**kwargs)
  update_local_settings(kwargs)
end