[csmaild-cvs] csmaild/src/Imap Connection.cs,1.5,1.6
Brought to you by:
tamc
From: <ta...@us...> - 2003-07-26 23:09:28
|
Update of /cvsroot/csmaild/csmaild/src/Imap In directory sc8-pr-cvs1:/tmp/cvs-serv31922/src/Imap Modified Files: Connection.cs Log Message: Modified network model to be asynchronous for idle times and synchronous during the processing of the command. This cleans up the code a bit, while still keeping some of the theoretical benefits of doing it asynchronously. Reworked some of the argument parsing Started work on the FETCH command The test client got some work to, nothing significant yet. Index: Connection.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/Imap/Connection.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Connection.cs 25 Jul 2003 03:39:12 -0000 1.5 --- Connection.cs 26 Jul 2003 23:09:25 -0000 1.6 *************** *** 49,60 **** } - public Connection Connection - { - get - { - return mConnection; - } - } - public ImapServer Server { --- 49,52 ---- *************** *** 100,105 **** mConnection.ReceivedLineEvent += new ReceivedLineDelegate(Connection_ReceivedLine); - mConnection.SentDataEvent += new SentDataDelegate(Connection_SentData); - ReadCommand(); } --- 92,95 ---- *************** *** 107,132 **** public void SendTaggedMessage(string msg) { ! SendTaggedMessage(mCurrentTag, msg); ! } ! public void SendTaggedMessage(string tag, string msg) ! { ! SendMessage(tag + " " + msg); } - public void SendUntaggedMessage(string msg) { SendMessage("* " + msg); } - public void SendContinueMessage(string msg) { SendMessage("+ " + msg); } - private void SendMessage(string msg) { mConnection.WriteLine(msg); } - public void ReadCommand() { --- 97,114 ---- public void SendTaggedMessage(string msg) { ! SendMessage(mCurrentTag + " " + msg); } public void SendUntaggedMessage(string msg) { SendMessage("* " + msg); } public void SendContinueMessage(string msg) { SendMessage("+ " + msg); } private void SendMessage(string msg) { mConnection.WriteLine(msg); } public void ReadCommand() { *************** *** 135,139 **** mCurrentCommand = null; ! mConnection.ReadLine(); } --- 117,133 ---- mCurrentCommand = null; ! mConnection.BeginReadLine(); ! } ! ! public string ReadLine() ! { ! return mConnection.ReadLine(); ! } ! ! public string ReadBlockAsString(int length) ! { ! byte[] buf = new byte[length]; ! mConnection.ReadBlock(buf, 0, length); ! return System.Text.Encoding.ASCII.GetString(buf); } *************** *** 195,216 **** // this command will parse through the incoming line and make sure it's valid ! if(ParseAndValidate(line)) ! { ! // good, leave the rest of the work up to the actual command handler ! mCurrentCommand.Process(); ! } ! else ! { ! // move on ! ReadCommand(); ! } ! } ! ! private void Connection_SentData(Connection con) ! { } public void Close() { } } --- 189,200 ---- // this command will parse through the incoming line and make sure it's valid ! if(ParseAndValidate(line) && mCurrentCommand.Process()) ! ;// good processing ! ReadCommand(); } public void Close() { + // TODO: gracefully handle closing of the connection } } |