Class: React::Rails::HotLoader::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/hot_loader/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: "0.0.0.0", port:, change_set_class: React::Rails::HotLoader::AssetChangeSet) ⇒ Server

Returns a new instance of Server.



9
10
11
12
13
14
# File 'lib/hot_loader/server.rb', line 9

def initialize(host: "0.0.0.0", port:, change_set_class: React::Rails::HotLoader::AssetChangeSet)
  @host = host
  @port = port
  @change_set_class = change_set_class
  @processed_msg = Hash.new
end

Instance Attribute Details

#change_set_classObject (readonly)

Returns the value of attribute change_set_class.



7
8
9
# File 'lib/hot_loader/server.rb', line 7

def change_set_class
  @change_set_class
end

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/hot_loader/server.rb', line 7

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/hot_loader/server.rb', line 7

def port
  @port
end

Instance Method Details

#restartObject

Restarts the server if it has stopped



17
18
19
20
21
22
23
24
25
# File 'lib/hot_loader/server.rb', line 17

def restart
  start
rescue StandardError => err
  if err.message =~ /no acceptor/
    React::Rails::HotLoader.log("WS server is already running (#{ws_url})")
  else
    React::Rails::HotLoader.error(err)
  end
end