diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-06-25 06:14:12 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-06-25 06:14:12 +0200 |
commit | fe332740f7c0be59d4ede7097e5bd1eabbf40e39 (patch) | |
tree | 57479ec89da0817bc043c8938ce27041607214a9 /src/core | |
parent | 3eb7e7688dea39fa83f41c1f9aba79a962ef1a15 (diff) | |
download | ephraim-fe332740f7c0be59d4ede7097e5bd1eabbf40e39.tar ephraim-fe332740f7c0be59d4ede7097e5bd1eabbf40e39.zip |
Chatting works now
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ephraim.erl | 18 | ||||
-rw-r--r-- | src/core/ephraim_conn.erl | 4 | ||||
-rw-r--r-- | src/core/ephraim_conv.erl | 11 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/core/ephraim.erl b/src/core/ephraim.erl index 61c3c68..c0ab7ae 100644 --- a/src/core/ephraim.erl +++ b/src/core/ephraim.erl @@ -97,6 +97,24 @@ loop(State) -> end, loop(State2); + {send_message, To, Type, Message} -> + {State2, Conv} = get_conv(State, To), + case Conv of + undefined -> + io:format("ephraim: send_message: ~p~n", [Message]); + _ -> + Conv ! {send_message, Type, Message} + end, + loop(State2); + + {start_conversation, To} -> + {State2, _Conv} = get_conv(State, To), + loop(State2); + + {send_packet, Packet} -> + State#state.conn ! {send_packet, Packet}, + loop(State); + {receive_event, From, Packet} -> State#state.event ! {receive_event, From, Packet}, loop(State); diff --git a/src/core/ephraim_conn.erl b/src/core/ephraim_conn.erl index bce4d07..7a6ddae 100644 --- a/src/core/ephraim_conn.erl +++ b/src/core/ephraim_conn.erl @@ -53,6 +53,10 @@ loop(State) -> ephraim ! {receive_iq, IQ}, loop(State); + {send_packet, Packet} -> + exmpp_session:send_packet(State#conn_state.session, Packet), + loop(State); + Msg -> io:format("ephraim_conn: ~p~n", [Msg]), loop(State) diff --git a/src/core/ephraim_conv.erl b/src/core/ephraim_conv.erl index 3010036..ac4c26d 100644 --- a/src/core/ephraim_conv.erl +++ b/src/core/ephraim_conv.erl @@ -19,7 +19,18 @@ loop(State) -> ok; {receive_message, Packet} -> + Type = exmpp_message:get_type(Packet), + Body = exmpp_message:get_body(Packet), io:format("Received message from ~p:~n~p~n", [State#conv_state.jid, Packet]), + ephraim ! {ui_update, {receive_message, State#conv_state.jid, Type, Body}}, + loop(State); + + {send_message, Type, Message} -> + Packet = exmpp_message:normal(Message), + Packet2 = exmpp_message:set_type(Packet, Type), + Packet3 = exmpp_xml:set_attribute(Packet2, to, State#conv_state.jid), + ephraim ! {send_packet, Packet3}, + ephraim ! {ui_update, {sent_message, State#conv_state.jid, Type, Message}}, loop(State); Msg -> |