【发布时间】:2017-09-20 09:25:04
【问题描述】:
在 ejabberd 模块中我使用这种方法:
httpc:request(post, {Url, Header
似乎不是异步的,erlang有没有办法在单独的线程上启动它???
【问题讨论】:
标签: erlang ejabberd ejabberd-module
在 ejabberd 模块中我使用这种方法:
httpc:request(post, {Url, Header
似乎不是异步的,erlang有没有办法在单独的线程上启动它???
【问题讨论】:
标签: erlang ejabberd ejabberd-module
我用过这个:
spawn(mod_http_offline, http_request, [Url, Post]).
% Function that make a call
http_request(Url, Post)->
TypeData = "application/x-www-form-urlencoded",
Header = [],
HTTPOptions = [],
Options = [],
httpc:request(post, {Url, Header, TypeData,list_to_binary(Post)}, HTTPOptions, Options).
但是当我编译时,得到这个:
Warning: function http_request/2 is unused
并且函数没有被调用
【讨论】:
Sample method-
// module name - sample
http_request(Method,Url,Body)->
httpc:request(Method, {Url, [], "application/x-www-form-urlencoded", Body}, [], []).
你会这样打电话的-
spawn(sample, http_request, [post,”www.sample.com”,”some sample data”]).
%% syntax spawn(Module, Name, Args) -> pid()
http://erlang.org/doc/getting_started/conc_prog.html http://erlang.org/doc/reference_manual/processes.html
【讨论】: