hedwig-im / hedwig

An Adapter-based Bot Framework for Elixir Applications
MIT License
650 stars 73 forks source link

Hedwig.whereis/1 not working #51

Closed colinrymer closed 7 years ago

colinrymer commented 7 years ago

A bot started with Hedwig.start_robot/2 or through the supervision tree doesn't register as a named process.

If you try calling Hedwig/which_robots/0, you get a return that looks like:

[{:undefined, #PID<0.193.0>, :worker, [Hedwig.Robot]}]
scrogson commented 7 years ago

Hi @colinrymer, the README is currently incorrect. Previously, I was auto-registering clients and have since removed that in order to ensure more flexibility.

The current solution is to do this in the after_connect/1 callback in your robot module.

defmodule MyApp.Robot do
  use Hedwig.Robot, otp_app: :my_app

  def after_connect(state) do
    Hedwig.Registry.register(state.name)

    {:ok, state}
  end
end

Sorry for the confusion. I'll update the README.

scrogson commented 7 years ago

Updated the README. Thanks for the report @colinrymer!