Poulet
This commit is contained in:
parent
fb9f95aa26
commit
bb72fdcc9a
@ -55,8 +55,8 @@ class start(QtGui.QDialog):
|
|||||||
exit(0)
|
exit(0)
|
||||||
try:
|
try:
|
||||||
self.s.send(cmd.encode())
|
self.s.send(cmd.encode())
|
||||||
# data , addr = s.recvfrom(4096)
|
data = self.s.recv(4096)
|
||||||
# print(data.decode())
|
print(data.decode())
|
||||||
except timeout:
|
except timeout:
|
||||||
print("Erreur : Timeout. Le serveur ne repond pas.")
|
print("Erreur : Timeout. Le serveur ne repond pas.")
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from serveur import Log
|
|||||||
|
|
||||||
|
|
||||||
def handleConnection(connection, client_address) :
|
def handleConnection(connection, client_address) :
|
||||||
try:
|
#try:
|
||||||
log.printL("Connection from IP -> {}".format(client_address), Log.lvl.INFO)
|
log.printL("Connection from IP -> {}".format(client_address), Log.lvl.INFO)
|
||||||
while True:
|
while True:
|
||||||
data = connection.recv(4096)
|
data = connection.recv(4096)
|
||||||
@ -16,12 +16,12 @@ def handleConnection(connection, client_address) :
|
|||||||
threading.Thread(target=handleRequest, args=(connection, data.decode())).start()
|
threading.Thread(target=handleRequest, args=(connection, data.decode())).start()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
except Exception as e :
|
"""except Exception as e :
|
||||||
log.printL(str(e), Log.lvl.FAIL)
|
log.printL(str(e), Log.lvl.FAIL)"""
|
||||||
|
|
||||||
|
|
||||||
def handleRequest(connection, data):
|
def handleRequest(connection, data):
|
||||||
try:
|
#try:
|
||||||
arrayData = data.split(" ")
|
arrayData = data.split(" ")
|
||||||
if(not arrayData[0][0] == "/"):
|
if(not arrayData[0][0] == "/"):
|
||||||
broadcastMsg( "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
|
broadcastMsg( "NEW_MSG {} {} ".format(usersConnected[connection][1], data))
|
||||||
@ -46,12 +46,13 @@ def handleRequest(connection, data):
|
|||||||
privateMsg(connection,arrayData[1],arrayData[2:])
|
privateMsg(connection,arrayData[1],arrayData[2:])
|
||||||
return
|
return
|
||||||
connection.send("ERR_COMMAND_NOT_FOUND".encode())
|
connection.send("ERR_COMMAND_NOT_FOUND".encode())
|
||||||
except Exception as e :
|
"""except Exception as e :
|
||||||
log.printL(str(e), Log.lvl.FAIL)
|
log.printL(str(e), Log.lvl.FAIL)"""
|
||||||
|
|
||||||
|
|
||||||
def broadcastMsg(message):
|
def broadcastMsg(message):
|
||||||
sock.sendall(message.encode())
|
for con, value in usersConnected.items() :
|
||||||
|
con.send(message.encode())
|
||||||
|
|
||||||
|
|
||||||
def userListActive(connection):
|
def userListActive(connection):
|
||||||
@ -132,11 +133,11 @@ def privateMsg(connection, pseudo, msg):
|
|||||||
|
|
||||||
|
|
||||||
def quit(connection) :
|
def quit(connection) :
|
||||||
broadcastMsg("HAS_LEFT {}".format(usersConnected[connection][1]))
|
|
||||||
connection.send("SUCCESSFUL_LOGOUT".encode())
|
connection.send("SUCCESSFUL_LOGOUT".encode())
|
||||||
connection.close()
|
connection.close()
|
||||||
usersConnected.__delitem__(connection)
|
|
||||||
log.printL("Disconnection from IP -> {}".format(usersConnected[connection][0]), Log.lvl.INFO)
|
log.printL("Disconnection from IP -> {}".format(usersConnected[connection][0]), Log.lvl.INFO)
|
||||||
|
usersConnected.pop(connection)
|
||||||
|
broadcastMsg("HAS_LEFT {}".format(usersConnected[connection][1]))
|
||||||
|
|
||||||
|
|
||||||
def getConnectionByPseudo(pseudo):
|
def getConnectionByPseudo(pseudo):
|
||||||
|
Reference in New Issue
Block a user