Server DNC
1.0
A TCP chat server implementation
|
Module server. More...
Functions | |
def | main () |
Load Configuration and Start the Server. More... | |
def | handle_connection (connection, client_address) |
Handle a connection from a client. More... | |
def | handle_request (connection, data) |
Handle a request. More... | |
def | broadcast_message (connection, message) |
Broadcast a message to all the users connected except to the sender of the request. More... | |
def | user_list_active (connection) |
Send the list of enable user. More... | |
def | user_list_away (connection) |
Send the list of disable user. More... | |
def | change_name (connection, pseudo) |
Change the nickname of the user. More... | |
def | new_name (connection, pseudo) |
Affect the nickname of the user for the first time. More... | |
def | ask_private_message (connection, pseudo) |
Ask for a private discussion between the sender of the request and the pseudo. More... | |
def | accept_private_message (connection, pseudo) |
Accept a private discussion. More... | |
def | reject_private_message (connection, pseudo) |
Reject a private discussion. More... | |
def | private_message (connection, pseudo, msg) |
Send a private message if a private discussion had been accepted. More... | |
def | ask_file (connection, pseudo, file) |
Ask for a file transfer between the sender of the request and the pseudo. More... | |
def | accept_file (connection, pseudo, file, port) |
Accept a file transfer. More... | |
def | reject_file (connection, pseudo, file) |
Reject a file transfer. More... | |
def | enable_user (connection) |
Enable user. More... | |
def | disable_user (connection) |
Disable user. More... | |
def | quit_user (connection) |
Disconnect user. More... | |
def | get_connection_by_pseudo (pseudo) |
Get the socket descriptor by a pseudo. More... | |
Module server.
def Server.accept_file | ( | connection, | |
pseudo, | |||
file, | |||
port | |||
) |
Accept a file transfer.
connection | the socket descriptor of the person who accept a file transfer |
pseudo | the pseudo of the person who asked for a file transfer |
def Server.accept_private_message | ( | connection, | |
pseudo | |||
) |
Accept a private discussion.
connection | the socket descriptor of the person who accept the private discussion |
pseudo | the pseudo of the person who asked for a private discussion |
def Server.ask_file | ( | connection, | |
pseudo, | |||
file | |||
) |
Ask for a file transfer between the sender of the request and the pseudo.
connection | the socket descriptor of the sender |
pseudo | the pseudo of target of the demand |
def Server.ask_private_message | ( | connection, | |
pseudo | |||
) |
Ask for a private discussion between the sender of the request and the pseudo.
connection | the socket descriptor of the sender |
pseudo | the pseudo of target of the demand |
def Server.broadcast_message | ( | connection, | |
message | |||
) |
Broadcast a message to all the users connected except to the sender of the request.
connection | the socket descriptor of the request sender |
message | message to broadcast (String) |
def Server.change_name | ( | connection, | |
pseudo | |||
) |
Change the nickname of the user.
connection | the socket descriptor of the target |
pseudo | new nickname for the user (String) |
def Server.disable_user | ( | connection | ) |
Disable user.
connection | the socket descriptor of the person to disable |
def Server.enable_user | ( | connection | ) |
Enable user.
connection | the socket descriptor of the person to enable |
def Server.get_connection_by_pseudo | ( | pseudo | ) |
Get the socket descriptor by a pseudo.
pseudo | pseudo |
def Server.handle_connection | ( | connection, | |
client_address | |||
) |
Handle a connection from a client.
Wait for request from the client
connection | the socket descriptor of the connection |
client_adress | ("ip", port) of the connection |
def Server.handle_request | ( | connection, | |
data | |||
) |
Handle a request.
connection | the socket descriptor of the request sender |
data | the request to handle in String |
def Server.main | ( | ) |
Load Configuration and Start the Server.
def Server.new_name | ( | connection, | |
pseudo | |||
) |
Affect the nickname of the user for the first time.
connection | the socket descriptor of the target |
pseudo | nickname for the user (String) |
def Server.private_message | ( | connection, | |
pseudo, | |||
msg | |||
) |
Send a private message if a private discussion had been accepted.
connection | the soccket descriptor of the sender |
pseudo | the pseudo of the private message target |
msg | the message to send |
def Server.quit_user | ( | connection | ) |
Disconnect user.
connection | the socket descriptor of the person to disconnect |
def Server.reject_file | ( | connection, | |
pseudo, | |||
file | |||
) |
Reject a file transfer.
connection | the socket descriptor of the person who reject a file transfer |
pseudo | the pseudo of the person who asked for a file transfer |
def Server.reject_private_message | ( | connection, | |
pseudo | |||
) |
Reject a private discussion.
connection | the socket descriptor of the person who reject private discussion |
pseudo | the pseudo of the person who asked for a private discussion |
def Server.user_list_active | ( | connection | ) |
Send the list of enable user.
connection | the socket descriptor of the target |
def Server.user_list_away | ( | connection | ) |
Send the list of disable user.
connection | the socket descriptor of the target |
int Server.ASKING_FOR_PM = 307 |
int Server.CAN_SEND_FILE = 313 |
int Server.COMMAND_NOT_FOUND = 407 |
int Server.DEST_NOT_FOUND = 403 |
int Server.ERR_ALREADY_ASKED_FOR_PM = 404 |
int Server.ERR_CONV_NOT_ALLOWED = 402 |
int Server.ERR_INTERNAL_SERVER_ERROR = 409 |
int Server.ERR_INVALID_NICKNAME = 408 |
int Server.ERR_NICKNAME_ALREADY_USED = 400 |
int Server.ERR_NO_INVIT_TO_CONV_FOUND = 405 |
int Server.ERR_NO_NICKNAME = 401 |
int Server.ERR_NOT_DISABLED = 410 |
int Server.ERR_NOT_ENABLED = 411 |
int Server.ERR_UNKNOWN_ACCEPTED_FILE = 406 |
int Server.HAS_ASKED_FILE = 312 |
int Server.HAS_JOIN = 302 |
int Server.HAS_LEFT = 303 |
int Server.HAS_REJECT_FILE = 314 |
int Server.IS_NOW_DISABLE = 311 |
int Server.IS_NOW_ENABLE = 310 |
int Server.NAME_CHANGED = 305 |
int Server.NEW_MSG = 304 |
int Server.NEW_PM = 306 |
int Server.PRIVATE_DISCU_ACCEPTED_FROM = 308 |
int Server.PRIVATE_DISCU_REFUSED_FROM = 309 |
int Server.SUCC_ACCEPTED_FILE = 212 |
int Server.SUCC_CHANNEL_JOINED = 200 |
int Server.SUCC_CHANNEL_QUIT = 201 |
int Server.SUCC_DISABLED = 210 |
int Server.SUCC_ENABLED = 209 |
int Server.SUCC_MESSAGE_SENDED = 202 |
int Server.SUCC_NICKNAME_CHANGED = 203 |
int Server.SUCC_PM_SENDED = 205 |
int Server.SUCC_PMFILE = 211 |
int Server.SUCC_REFUSED_FILE = 213 |
int Server.SUCCESSFUL_ACCEPTED_CONV = 207 |
int Server.SUCCESSFUL_ASKED_CONV = 206 |
int Server.SUCCESSFUL_REFUSED_CONV = 208 |
int Server.USERLIST_DISABLE = 301 |
int Server.USERLIST_ENABLE = 300 |