-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCLogon.cpp
More file actions
50 lines (33 loc) · 1.1 KB
/
SCLogon.cpp
File metadata and controls
50 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "SCLogon.h"
#include "SCChat.h"
#include "SCUserDB.h"
using namespace SocketLib;
void SCLogon::Handle( string p_data )
{
Connection<Telnet>* conn = m_connection;
if( !UserDatabase::IsValidName( p_data ) )
{
conn->Protocol().SendString( *conn, red + bold +
"Sorry, that is an invalid username.\r\n" +
"Please enter another username: " + reset + bold );
return;
}
if( UserDatabase::HasUser( p_data ) )
{
conn->Protocol().SendString( *conn, red + bold +
"Sorry, that name is already in use.\r\n" +
"Please enter another username: " + reset );
return;
}
UserDatabase::AddUser( conn, p_data );
conn->Protocol().SendString( *conn, "Thank you for joining us, " +
p_data + newline );
conn->AddHandler( new SCChat( *conn ) );
}
void SCLogon::Enter()
{
// welcome the new user
m_connection->Protocol().SendString( *m_connection,
green + bold + "Welcome To SimpleChat!\r\n" +
"Please enter your username: " + reset + bold );
}