![]() |
ChatSocket Class Reference#include <ChatSocket.h>
Detailed Description
Definition at line 33 of file ChatSocket.h. Constructor & Destructor Documentation
Definition at line 28 of file ChatSocket.cpp. 00029 :TcpSocket(h) 00030 ,m_state(STATE_LOGIN) 00031 ,m_name("") 00032 { 00033 SetLineProtocol(); 00034 }
Member Function Documentation
Definition at line 42 of file ChatSocket.cpp. References SendPrompt(). 00043 { 00044 Send("Welcome.\n"); 00045 SendPrompt(); 00046 }
Definition at line 49 of file ChatSocket.cpp. References m_name, m_state, SendPrompt(), STATE_LOGIN, STATE_PROMPT, and STATE_QUIT. 00050 { 00051 switch (m_state) 00052 { 00053 case STATE_LOGIN: 00054 if (line.size()) 00055 { 00056 m_name = line; 00057 m_state = STATE_PROMPT; 00058 } 00059 SendPrompt(); 00060 break; 00061 case STATE_PROMPT: 00062 if (line.size()) 00063 { 00064 if (line == "/who") 00065 { 00066 static_cast<ChatHandler&>(Handler()).Who(this); 00067 } 00068 else 00069 if (line == "/quit") 00070 { 00071 m_state = STATE_QUIT; 00072 } 00073 else 00074 { 00075 static_cast<ChatHandler&>(Handler()).Talk(m_name,line); 00076 } 00077 } 00078 SendPrompt(); 00079 break; 00080 case STATE_QUIT: 00081 break; 00082 } 00083 }
Definition at line 86 of file ChatSocket.cpp. References m_state, STATE_LOGIN, STATE_PROMPT, and STATE_QUIT. Referenced by OnAccept(), and OnLine(). 00087 { 00088 switch (m_state) 00089 { 00090 case STATE_LOGIN: 00091 Send("Enter name: "); 00092 break; 00093 case STATE_PROMPT: 00094 Send("> "); 00095 break; 00096 case STATE_QUIT: 00097 Send("Goodbye!\n"); 00098 SetCloseAndDelete(); 00099 break; 00100 } 00101 }
Member Data Documentation
The documentation for this class was generated from the following files: |