summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--ephraim.erl22
-rw-r--r--ephraim_conn.erl49
-rw-r--r--ephraim_conv.erl18
4 files changed, 91 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..27d389a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*.beam
+*~ \ No newline at end of file
diff --git a/ephraim.erl b/ephraim.erl
new file mode 100644
index 0000000..0aff011
--- /dev/null
+++ b/ephraim.erl
@@ -0,0 +1,22 @@
+-module(ephraim).
+-compile([debug_info, export_all]).
+
+start() ->
+ Pid = spawn(?MODULE, init, []),
+ register(ephraim, Pid).
+
+stop() ->
+ ephraim ! stop.
+
+init() ->
+ Conn = spawn(ephraim_conn, init, []),
+ loop(Conn).
+
+loop(Conn) ->
+ receive
+ stop ->
+ Conn ! stop;
+ Msg ->
+ io:format("ephraim: ~p~n", [Msg]),
+ loop(Conn)
+ end.
diff --git a/ephraim_conn.erl b/ephraim_conn.erl
new file mode 100644
index 0000000..009d38d
--- /dev/null
+++ b/ephraim_conn.erl
@@ -0,0 +1,49 @@
+-module(ephraim_conn).
+-include_lib("exmpp/include/exmpp_client.hrl").
+-compile([debug_info, export_all]).
+
+-record(conn_state, {
+ session :: any(),
+ roster :: any()
+ }).
+
+init() ->
+ application:start(exmpp),
+ Session = exmpp_session:start(),
+ JID = exmpp_jid:make("ephraim-test", "jabber.ccc.de", "Bar"),
+ exmpp_session:auth_basic_digest(Session, JID, "foobarbla"),
+ exmpp_session:connect_TCP(Session, "jabber.ccc.de", 5222),
+ session(#conn_state{session=Session}).
+
+session(State) ->
+ exmpp_session:login(State#conn_state.session),
+ exmpp_session:send_packet(State#conn_state.session, exmpp_presence:set_status(exmpp_presence:available(), "Foo/Test\\Bar")),
+ loop(State).
+
+loop(State) ->
+ receive
+ stop ->
+ exmpp_session:stop(State#conn_state.session);
+
+ #received_packet{packet_type=presence, raw_packet=Packet} ->
+ From = exmpp_xml:get_attribute(Packet, from, <<"unknown">>),
+ Type = atom_to_list(exmpp_presence:get_type(Packet)),
+ Status = exmpp_presence:get_status(Packet),
+ io:format("~ts is now ~ts: ~ts~n", [From, Type, Status]),
+ loop(State);
+
+ #received_packet{packet_type=message, raw_packet=Packet} ->
+ case exmpp_message:get_type(Packet) of
+ chat ->
+ From = exmpp_xml:get_attribute(Packet, from, <<"unknown">>),
+ Body = exmpp_message:get_body(Packet),
+ io:format("~ts: ~ts~n", [From, Body]);
+ _ ->
+ ok
+ end,
+ loop(State);
+
+ Msg ->
+ io:format("ephraim_conn: ~p~n", [Msg]),
+ loop(State)
+ end.
diff --git a/ephraim_conv.erl b/ephraim_conv.erl
new file mode 100644
index 0000000..c6243fa
--- /dev/null
+++ b/ephraim_conv.erl
@@ -0,0 +1,18 @@
+-module(ephraim_conv).
+-compile([debug_info, export_all]).
+
+-record(conv_state, {
+ jid :: binary()
+ }).
+
+init(JID) ->
+ loop(#conv_state{jid=JID}).
+
+loop(State) ->
+ receive
+ stop ->
+ ok;
+ Msg ->
+ io:format("ephraim_conv: ~p~n", [Msg]),
+ loop(State)
+ end.