Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(message_router2).
- -compile(export_all).
- start() ->
- spawn(message_router2, route_messages, []).
- stop(RouterPid) ->
- RouterPid ! shutdown.
- route_messages() ->
- receive
- {send_chat_msg, Addressee, MessageBody} ->
- Addressee ! {recv_chat_msg, MessageBody},
- route_messages();
- {recv_chat_msg, MessageBody} ->
- io:format("Received: ~p~n", [MessageBody]);
- shutdown ->
- io:format("Shutting down~n");
- Oops ->
- io:format("Warning! Received: ~p~n", [Oops]),
- route_messages()
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement