ejabberd - Comments for "ODBC connection in http-bind" https://www.ejabberd.im/node/4766 en rysi3k wrote: Thanks, it https://www.ejabberd.im/node/4766#comment-57571 <div class="quote-msg"> <div class="quote-author"><em>rysi3k</em> wrote:</div> <p>Thanks, it works, but I have idea, to put this functionality (db query) to different module.<br /> So I want to execute query, from other module when the session timeouts.<br /> Can I do this by any callback (in gen_fsm?) or other way ?</p></div> <p>The only way I can think is that, in ejabberd_http_bind.erl you call<br /> yourmod:run_sql_query(["SELECT VERSION()"])</p> <p>And in yourmod.erl you define and export the function.</p> Sat, 09 Jul 2011 11:39:48 +0000 mfoss comment 57571 at https://www.ejabberd.im Thanks, it works, but I have https://www.ejabberd.im/node/4766#comment-57561 <p>Thanks, it works, but I have idea, to put this functionality (db query) to different module.<br /> So I want to execute query, from other module when the session timeouts.<br /> Can I do this by any callback (in gen_fsm?) or other way ?</p> Tue, 05 Jul 2011 12:33:59 +0000 rysi3k comment 57561 at https://www.ejabberd.im I think that the function https://www.ejabberd.im/node/4766#comment-57488 <p>I think that the function call needs to be inside a transaction, something like this:</p> <pre> handle_info({timeout, Timer, _}, _StateName, #state{id=SID, timer = Timer} = StateData) -&gt; ?INFO_MSG("Session timeout. Closing the HTTP bind session: ~p", [SID]), %% This picks the first vhost defined in 'hosts' in ejabberd.cfg LServer = ?MYNAME, F = fun() -&gt; run_sql_query(["SELECT VERSION()"]) end, Res = run_sql_transaction(LServer, F). ?INFO_MSG("Result of my SQL query: ~p", [Res]), {stop, normal, StateData}; </pre> Tue, 14 Jun 2011 10:33:04 +0000 mfoss comment 57488 at https://www.ejabberd.im