ULTIMATE SERVER DE LA MUERTE V2.0
This commit is contained in:
parent
4836141b2d
commit
f0f3dbcfed
@ -20,16 +20,18 @@ def handleConnection(connection, client_address):
|
|||||||
|
|
||||||
|
|
||||||
def handleRequest(connection, data):
|
def handleRequest(connection, data):
|
||||||
#try:
|
try:
|
||||||
arrayData = data.split(" ")
|
arrayData = data.split(" ")
|
||||||
|
|
||||||
### Command for user with nickname ###
|
### Command for user with nickname ###
|
||||||
if usersConnected[connection][1] is not None:
|
if usersConnected[connection][1] is not None:
|
||||||
|
### No command -> new message ###
|
||||||
if not arrayData[0][0] == "/" and usersConnected[connection][2]:
|
if not arrayData[0][0] == "/" and usersConnected[connection][2]:
|
||||||
connection.sendall("SUCC_MESSAGE_SENDED".encode())
|
connection.sendall("SUCC_MESSAGE_SENDED".encode())
|
||||||
broadcastMsg(connection, "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
|
broadcastMsg(connection, "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
### Command for user enable & disable ###
|
||||||
if arrayData[0] == "/name":
|
if arrayData[0] == "/name":
|
||||||
changeName(connection, arrayData[1])
|
changeName(connection, arrayData[1])
|
||||||
return
|
return
|
||||||
@ -77,7 +79,7 @@ def handleRequest(connection, data):
|
|||||||
return
|
return
|
||||||
connection.sendall("ERR_COMMAND_NOT_FOUND".encode())
|
connection.sendall("ERR_COMMAND_NOT_FOUND".encode())
|
||||||
else:
|
else:
|
||||||
### Command for user without nickname
|
### Command for user without nickname ###
|
||||||
if arrayData[0] == "/newname":
|
if arrayData[0] == "/newname":
|
||||||
newName(connection, arrayData[1])
|
newName(connection, arrayData[1])
|
||||||
return
|
return
|
||||||
@ -85,12 +87,12 @@ def handleRequest(connection, data):
|
|||||||
connection.shutdown(socket.SHUT_RD)
|
connection.shutdown(socket.SHUT_RD)
|
||||||
return
|
return
|
||||||
connection.sendall("ERR_NO_NICKNAME".encode())
|
connection.sendall("ERR_NO_NICKNAME".encode())
|
||||||
"""except IndexError:
|
except IndexError:
|
||||||
log.printL("Parameter missing in the request", Log.lvl.WARNING)
|
log.printL("Parameter missing in the request", Log.lvl.WARNING)
|
||||||
connection.sendall("ERR_PARAMETER_MISSING".encode())
|
connection.sendall("ERR_PARAMETER_MISSING".encode())
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
log.printL("Handle request fail : {}".format(str(e)), Log.lvl.FAIL)
|
log.printL("Handle request fail : {}".format(str(e)), Log.lvl.FAIL)
|
||||||
connection.sendall("ERR_INTERNAL_SERVER_ERROR".encode())"""
|
connection.sendall("ERR_INTERNAL_SERVER_ERROR".encode())
|
||||||
|
|
||||||
|
|
||||||
def broadcastMsg(connection, message):
|
def broadcastMsg(connection, message):
|
||||||
|
Reference in New Issue
Block a user