Hi all,<br><br>The IRC Lite example in "programming erlang" makes me think some question that I thought I have understood.<br><br>1. Which part of parent process should receive 'EXIT' message when child process exit(reason) after sending parent a normal message ? <br>
So in the chat_client.erl,<br><br>try_to_connect(Parent, Host, Port, Pwd) -><br> ...<br> Parent ! {<b>connected, MM</b>},<br> exit(<b>connectorFinished</b>)<br> end.<br><br>While in parents <b>disconnected/3</b>, <br>
...<br> receive<br> {<b>connected, MM</b>} -><br> ...<br> <b>wait_login_response</b>(Widget, MM);<br> {<b>'EXIT', _Pid, _Reason</b>} -> %% if we add this clause here<br>...<br><b>wait_login_response/2</b> defines,<br>
...<br> receive<br> { {<b>'EXIT', _Pid, _Reason</b>} -> %% it actually just define Other -> ...<br>...<br><br>The result shows that wait_login_response/2 receives the 'EXIT' message not disconnected/3. I further test that if try_to_connect sends more messages after {<b>connected, MM</b>} , they will all be received by wait_login_response instead of disconnected/3 even there are match patterns in disconnected/3 (Correct me if I am wrong). So for a general cases, is this a good idea (design) to make the first message match part receives the remaining messages after the first match (if the first match part has its own receive loop) instead of the other part of receiving function ? Or I miss something here ?<br>
<br>2. Why mod_chat_controller <b>only </b>receives login message ? After all, chat_client uses lib_chan_mm:send(MM) for both login and relay messages ?<br><br>3. When I close a window, except for the expected message "I'm leaving the group", the server also output the error message "server error should die with exit(normal) was:{mm_closed,<xxx>}". Why does this happen and how to fix it ?<br>
<br>Thanks!<br><br>Qiulang<br><br><br><br>