Skip to content

Instantly share code, notes, and snippets.

@mweibel
Created October 5, 2012 06:05
Show Gist options
  • Save mweibel/3838341 to your computer and use it in GitHub Desktop.
Save mweibel/3838341 to your computer and use it in GitHub Desktop.
mod_onlineusers with list of users online
%%%----------------------------------------------------------------------
%%% File : mod_onlineusers.erl
%%% Author : Michael Weibel <[email protected]>
%%% Purpose : Display number & list of online users
%%% Created : 2011-08-16
%%%----------------------------------------------------------------------
-module(mod_onlineusers).
-author('[email protected]').
-behaviour(gen_mod).
-export([
start/2,
stop/1,
process/2
]).
-include("ejabberd.hrl").
-include("jlib.hrl").
-include("web/ejabberd_http.hrl").
%%%----------------------------------------------------------------------
%%% REQUEST HANDLERS
%%%----------------------------------------------------------------------
process([], _Request) ->
{200, [], integer_to_list(ejabberd_sm:connected_users_number())};
process(["list"], _Request) ->
{200, [], ejabberd_sm:connected_users()};
%%%----------------------------------------------------------------------
%%% BEHAVIOUR CALLBACKS
%%%----------------------------------------------------------------------
start(_Host, _Opts) ->
ok.
stop(_Host) ->
ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment