# Server DNC: serveur.Server Namespace Reference

serveur.Server Namespace Reference

## 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...

## Variables

int | USERLIST_ENABLE = 300
| Code retour ### INFO. More...
int | USERLIST_DISABLE = 301
int | HAS_JOIN = 302
int | HAS_LEFT = 303
int | NEW_MSG = 304
int | NAME_CHANGED = 305
int | NEW_PM = 306
int | ASKING_FOR_PM = 307
int | PRIVATE_DISCU_ACCEPTED_FROM = 308
int | PRIVATE_DISCU_REFUSED_FROM = 309
int | IS_NOW_ENABLE = 310
int | IS_NOW_DISABLE = 311
int | HAS_ASKED_FILE = 312
int | CAN_SEND_FILE = 313
int | HAS_REJECT_FILE = 314
int | SUCC_CHANNEL_JOINED = 200
| SUCCESS. More...
int | SUCC_CHANNEL_QUIT = 201
int | SUCC_MESSAGE_SENDED = 202
int | SUCC_NICKNAME_CHANGED = 203
int | SUCC_PM_SENDED = 205
int | SUCCESSFUL_ASKED_CONV = 206
int | SUCCESSFUL_ACCEPTED_CONV = 207
int | SUCCESSFUL_REFUSED_CONV = 208
int | SUCC_ENABLED = 209
int | SUCC_DISABLED = 210
int | SUCC_PMFILE = 211
int | SUCC_ACCEPTED_FILE = 212
int | SUCC_REFUSED_FILE = 213
int | ERR_NICKNAME_ALREADY_USED = 400
| ERROR. More...
int | ERR_NO_NICKNAME = 401
int | ERR_CONV_NOT_ALLOWED = 402
int | DEST_NOT_FOUND = 403
int | ERR_ALREADY_ASKED_FOR_PM = 404
int | ERR_NO_INVIT_TO_CONV_FOUND = 405
int | ERR_UNKNOWN_ACCEPTED_FILE = 406
int | COMMAND_NOT_FOUND = 407
int | ERR_INVALID_NICKNAME = 408
int | ERR_INTERNAL_SERVER_ERROR = 409
int | ERR_NOT_DISABLED = 410
int | ERR_NOT_ENABLED = 411

## Function Documentation

def serveur.Server.accept_file | ( |  | connection,
|  |  | pseudo,
|  |  | file,
|  |  | port
| ) |  |

Accept a file transfer.

Parameters

  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 serveur.Server.accept_private_message | ( |  | connection,
|  |  | pseudo
| ) |  |

Accept a private discussion.

Parameters

  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 serveur.Server.ask_file | ( |  | connection,
|  |  | pseudo,
|  |  | file
| ) |  |

Ask for a file transfer between the sender of the request and the pseudo.

Parameters

  connection | the socket descriptor of the sender
  pseudo | the pseudo of target of the demand

def serveur.Server.ask_private_message | ( |  | connection,
|  |  | pseudo
| ) |  |

Ask for a private discussion between the sender of the request and the pseudo.

Parameters

  connection | the socket descriptor of the sender
  pseudo | the pseudo of target of the demand

def serveur.Server.broadcast_message | ( |  | connection,
|  |  | message
| ) |  |

Broadcast a message to all the users connected except to the sender of the request.

Parameters

  connection | the socket descriptor of the request sender
  message | message to broadcast (String)

def serveur.Server.change_name | ( |  | connection,
|  |  | pseudo
| ) |  |

Change the nickname of the user.

Parameters

  connection | the socket descriptor of the target
  pseudo | new nickname for the user (String)

def serveur.Server.disable_user | ( |  | connection | ) |

Disable user.

Parameters

  connection | the socket descriptor of the person to disable

def serveur.Server.enable_user | ( |  | connection | ) |

Enable user.

Parameters

  connection | the socket descriptor of the person to enable

def serveur.Server.get_connection_by_pseudo | ( |  | pseudo | ) |

Get the socket descriptor by a pseudo.

Parameters

  pseudo | pseudo

Returns
  the socket descriptor of the pseudo or None

def serveur.Server.handle_connection | ( |  | connection,
|  |  | client_address
| ) |  |

Handle a connection from a client.

Wait for request from the client

Parameters

  connection | the socket descriptor of the connection
  client_adress | ("ip", port) of the connection

def serveur.Server.handle_request | ( |  | connection,
|  |  | data
| ) |  |

Handle a request.

Parameters

  connection | the socket descriptor of the request sender
  data | the request to handle in String

def serveur.Server.main | ( |  | ) |

Load Configuration and Start the Server.

def serveur.Server.new_name | ( |  | connection,
|  |  | pseudo
| ) |  |

Affect the nickname of the user for the first time.

Parameters

  connection | the socket descriptor of the target
  pseudo | nickname for the user (String)

def serveur.Server.private_message | ( |  | connection,
|  |  | pseudo,
|  |  | msg
| ) |  |

Send a private message if a private discussion had been accepted.

Parameters

  connection | the soccket descriptor of the sender
  pseudo | the pseudo of the private message target
  msg | the message to send

def serveur.Server.quit_user | ( |  | connection | ) |

Disconnect user.

Parameters

  connection | the socket descriptor of the person to disconnect

def serveur.Server.reject_file | ( |  | connection,
|  |  | pseudo,
|  |  | file
| ) |  |

Reject a file transfer.

Parameters

  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 serveur.Server.reject_private_message | ( |  | connection,
|  |  | pseudo
| ) |  |

Reject a private discussion.

Parameters

  connection | the socket descriptor of the person who reject private discussion
  pseudo | the pseudo of the person who asked for a private discussion

def serveur.Server.user_list_active | ( |  | connection | ) |

Send the list of enable user.

Parameters

  connection | the socket descriptor of the target

def serveur.Server.user_list_away | ( |  | connection | ) |

Send the list of disable user.

Parameters

  connection | the socket descriptor of the target

## Variable Documentation

int serveur.Server.ASKING_FOR_PM = 307

int serveur.Server.CAN_SEND_FILE = 313

int serveur.Server.COMMAND_NOT_FOUND = 407

int serveur.Server.DEST_NOT_FOUND = 403

int serveur.Server.ERR_ALREADY_ASKED_FOR_PM = 404

int serveur.Server.ERR_CONV_NOT_ALLOWED = 402

int serveur.Server.ERR_INTERNAL_SERVER_ERROR = 409

int serveur.Server.ERR_INVALID_NICKNAME = 408

int serveur.Server.ERR_NICKNAME_ALREADY_USED = 400

ERROR.

int serveur.Server.ERR_NO_INVIT_TO_CONV_FOUND = 405

int serveur.Server.ERR_NO_NICKNAME = 401

int serveur.Server.ERR_NOT_DISABLED = 410

int serveur.Server.ERR_NOT_ENABLED = 411

int serveur.Server.ERR_UNKNOWN_ACCEPTED_FILE = 406

int serveur.Server.HAS_ASKED_FILE = 312

int serveur.Server.HAS_JOIN = 302

int serveur.Server.HAS_LEFT = 303

int serveur.Server.HAS_REJECT_FILE = 314

int serveur.Server.IS_NOW_DISABLE = 311

int serveur.Server.IS_NOW_ENABLE = 310

int serveur.Server.NAME_CHANGED = 305

int serveur.Server.NEW_MSG = 304

int serveur.Server.NEW_PM = 306

int serveur.Server.PRIVATE_DISCU_ACCEPTED_FROM = 308

int serveur.Server.PRIVATE_DISCU_REFUSED_FROM = 309

int serveur.Server.SUCC_ACCEPTED_FILE = 212

int serveur.Server.SUCC_CHANNEL_JOINED = 200

SUCCESS.

int serveur.Server.SUCC_CHANNEL_QUIT = 201

int serveur.Server.SUCC_DISABLED = 210

int serveur.Server.SUCC_ENABLED = 209

int serveur.Server.SUCC_MESSAGE_SENDED = 202

int serveur.Server.SUCC_NICKNAME_CHANGED = 203

int serveur.Server.SUCC_PM_SENDED = 205

int serveur.Server.SUCC_PMFILE = 211

int serveur.Server.SUCC_REFUSED_FILE = 213

int serveur.Server.SUCCESSFUL_ACCEPTED_CONV = 207

int serveur.Server.SUCCESSFUL_ASKED_CONV = 206

int serveur.Server.SUCCESSFUL_REFUSED_CONV = 208

int serveur.Server.USERLIST_DISABLE = 301

int serveur.Server.USERLIST_ENABLE = 300

Code retour ### INFO.