I am unable to use `ejabberd_auth` in my **helloworld** project

只愿长相守 提交于 2019-12-18 08:48:53

问题


I am unable to use ejabberd_auth in my helloworld project.

-behaviour(ejabberd_auth). 
... 
....  
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).  

With that I get the error warning:

helloworld.erl:15: Warning: behaviour ejabberd_auth undefined    


-import(ejabberd_auth, [try_register/3]).  
... 
....  
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).  

With this I get:

exception error: undefined function ejabberd_auth:try_register/3  

Why am I unable to access ejabberd_auth?

I am using IntelliJ Idea, with the Erlang plugin installed.

Thank you all in advance.

UPDATE:
I'm on Ubuntu 16.04 LTS


回答1:


I can get you past that error. Here's how...

When I compile a module in the erlang shell, the compiler creates a .beam file in the same directory, which allows me to call functions defined in the module. In your case, if you cd into the directory:

 .../ejabberd/ebin 

you will see all the ejabberd .beam files, including ejabberd_auth.beam. If you start an erlang shell in that directory, then issue your function call (don't compile anything), you won't get that error anymore.

But, then I get the error:

exception error: undefined function jid:nodeprep/1
     in function  ejabberd_auth:validate_credentials/3 (src/ejabberd_auth.erl, line 796)
     in call from ejabberd_auth:try_register/3 (src/ejabberd_auth.erl, line`

There is no jid.beam file in that directory. But:

~/Downloads/ejabberd$ find . -name jid.beam
./deps/xmpp/ebin/jid.beam

You are going to have to figure out how to compile your module so that all the ejabberd modules are available to your program. See: ejabberd how to compile new module.

I am unable to use ejabberd_auth in my helloworld project.

Are you following a tutorial somewhere?



来源:https://stackoverflow.com/questions/49220369/i-am-unable-to-use-ejabberd-auth-in-my-helloworld-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!