This commit is contained in:
sidya82 2015-04-02 13:47:02 +02:00
parent d5baaa74d2
commit 9030013c68
5 changed files with 15 additions and 33 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.idea/
__pycache__/
log

View File

@ -1,27 +0,0 @@
2015-04-01 08:42:26,046 :: INFO ::  Configuration load Namespace(port=8000, usermax=None) 
2015-04-01 08:42:26,046 :: INFO ::  Server start 
2015-04-01 08:42:26,088 :: INFO ::  Server Listen on port 8000 
2015-04-01 08:43:10,939 :: INFO ::  Wait for threads ending 
2015-04-01 08:43:10,940 :: INFO ::  Server shutdown 
2015-04-01 08:43:21,055 :: INFO ::  Configuration load Namespace(port=2222, usermax=None) 
2015-04-01 08:43:21,055 :: INFO ::  Server start 
2015-04-01 08:43:21,058 :: INFO ::  Server Listen on port 2222 
2015-04-01 08:43:32,103 :: INFO ::  Connection from IP -> ('127.0.0.1', 53851) 
2015-04-01 08:43:39,933 :: INFO ::  Request from IP -> ('127.0.0.1', 53851) bob 
2015-04-01 08:43:45,900 :: INFO ::  Request from IP -> ('127.0.0.1', 53851) super ! 
2015-04-01 08:43:52,170 :: INFO ::  Request from IP -> ('127.0.0.1', 53851) /name bob 
2015-04-01 08:44:08,771 :: INFO ::  Connection from IP -> ('127.0.0.1', 53852) 
2015-04-01 08:44:12,601 :: INFO ::  Request from IP -> ('127.0.0.1', 53852) /quit 
2015-04-01 08:44:45,278 :: INFO ::  Wait for threads ending 
2015-04-01 08:44:45,278 :: INFO ::  Disconnection from IP -> ('127.0.0.1', 53851) 
2015-04-01 14:01:21,465 :: INFO ::  Configuration load Namespace(port=8000, usermax=None) 
2015-04-01 14:01:21,476 :: INFO ::  Server start 
2015-04-01 14:01:21,508 :: INFO ::  Server Listen on port 8000 
2015-04-01 14:01:59,767 :: INFO ::  Connection from IP -> ('127.0.0.1', 60151) 
2015-04-01 14:02:04,760 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) coucou 
2015-04-01 14:02:20,518 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) /name bob 
2015-04-01 14:03:35,380 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) /newname bob 
2015-04-01 14:03:38,491 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) coucou 
2015-04-01 14:03:48,807 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) /newname 
2015-04-01 14:03:56,293 :: INFO ::  Request from IP -> ('127.0.0.1', 60151) /newname renan 
2015-04-01 14:04:53,177 :: INFO ::  Connection from IP -> ('127.0.0.1', 60182) 

View File

View File

View File

@ -23,8 +23,6 @@ def handleConnection(connection, client_address) :
def handleRequest(connection, data):
#try:
arrayData = data.split(" ")
if arrayData[0] == "/newname" :
pass
if usersConnected[connection][1] is not None :
if(not arrayData[0][0] == "/"):
broadcastMsg( "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
@ -33,9 +31,6 @@ def handleRequest(connection, data):
if arrayData[0] == "/name" :
changeName(connection, arrayData[1])
return
if arrayData[0] == "/quit" :
quit(connection)
return
if arrayData[0] == "/askpm" :
askPrivateMsg(connection,arrayData[1])
return
@ -56,6 +51,12 @@ def handleRequest(connection, data):
return
connection.send("ERR_COMMAND_NOT_FOUND".encode())
else:
if arrayData[0] == "/newname" :
newName(connection)
return
if arrayData[0] == "/quit" :
quit(connection)
return
connection.send("CMD_NOT_ALLOWED".encode())
"""except Exception as e :
log.printL(str(e), Log.lvl.FAIL)"""
@ -63,7 +64,8 @@ def handleRequest(connection, data):
def broadcastMsg(message):
for con, value in usersConnected.items() :
con.send(message.encode())
if usersConnected[con][1] is not None :
con.send(message.encode())
def userListActive(connection):
@ -87,6 +89,12 @@ def changeName(connection, pseudo):
usersConnected[connection][1] = pseudo
def newName(connection, pseudo):
broadcastMsg("HAS_JOIN {} ".format(pseudo))
connection.send("SUCC_VALID_NICKNAME")
usersConnected[connection][1] = pseudo
def askPrivateMsg(connection,pseudo):
c = getConnectionByPseudo(pseudo)
if c is None :