Module: WebSocket::InstanceMethods
- Included in:
- Server
- Defined in:
- lib/websocket/instance_methods.rb
Overview
The InstanceMethods module
Instance Method Summary collapse
- #channel_initializer ⇒ Object
- #log_requests? ⇒ Boolean
-
#port ⇒ Object
rubocop: enable Metrics/AbcSize rubocop: enable Metrics/MethodLength.
-
#run(params = {}) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
Instance Method Details
#channel_initializer ⇒ Object
26 27 28 |
# File 'lib/websocket/instance_methods.rb', line 26 def channel_initializer @channel_initializer ||= ::WebSocket::ChannelInitializer.new(channel_group, @options) end |
#log_requests? ⇒ Boolean
53 54 55 56 57 58 |
# File 'lib/websocket/instance_methods.rb', line 53 def log_requests? @log_requests ||= begin value = @options[:log_requests] value.nil? ? DEFAULT_LOG_REQUESTS : value end end |
#port ⇒ Object
rubocop: enable Metrics/AbcSize rubocop: enable Metrics/MethodLength
49 50 51 |
# File 'lib/websocket/instance_methods.rb', line 49 def port @port ||= (@options[:ssl] ? @options[:ssl_port] : @options[:port]).to_i end |
#run(params = {}) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/websocket/instance_methods.rb', line 32 def run(params = {}) @options.merge!(params) channel = bootstrap.bind(port).sync().channel() channel_group.add(channel) ::WebSocket::ShutdownHook.new(self) log.info "Listening on #{channel.local_address}" channel.closeFuture().sync() rescue java.net.BindException => e raise "Bind error: #{e.}: #{@options[:host]}:#{port}" rescue java.net.SocketException => e raise "Socket error: #{e.}: #{@options[:host]}:#{port}" ensure stop end |