# frozen_string_literal: true
require_relative './connection_data'

module Hypertube
  module Utils
    class WsConnectionData < ConnectionData
      DEFAULT_CONNECT_TIMEOUT_SECONDS = 60

      attr_accessor :hostname, :connect_timeout

      def initialize(hostname, connect_timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS)
        super()
        @hostname = hostname
        @connect_timeout = connect_timeout
      end

      def connection_type
        Hypertube::Utils::ConnectionType::WEB_SOCKET
      end

      def serialize_connection_data
        [connection_type, 0, 0, 0, 0, 0, 0]
      end

      def to_s
        "websocket|#{@hostname}"
      end

      private

    end
  end
end
