C-chat
Classes | Typedefs | Functions | Variables
packets.h File Reference

Defines types of packets that are exchanged between client and server. More...

#include "constants.h"
#include "sockets.h"

Go to the source code of this file.

Classes

class  PacketJoin
 This packet is sent to all client of a room when a client joins the room. More...
 
class  PacketLeave
 This packet is sent to all client of a room when a client leaves the room. More...
 
class  PacketText
 This packet is sent to all clients of a room when a client sends a message. More...
 
class  PacketDefineUsername
 This packet is sent to server by client to re-define its username. More...
 
class  PacketServerErrorMessage
 This packet is sent by server to an user when an error occurs. More...
 
class  PacketUsernameChanged
 This packet is sent to all client of a room when an user of the room changes its username. More...
 
class  PacketQuit
 This packet is sent to server by client to notify him he wants to quit the room. More...
 
class  PacketFileUploadRequest
 This packet is sent to server to ask for file upload. More...
 
class  PacketFileDownloadRequest
 This packet is sent to server to ask for file download. More...
 
class  PacketFileUploadValidation
 This packet is sent to client by server to accept/reject a file upload. More...
 
class  PacketFileDownloadValidation
 This packet is sent to client by server to accept/reject a file download. More...
 
class  PacketFileDataTransfer
 This packet is exchanged between client and server to transfer file content. More...
 
class  PacketFileTransferCancel
 This packet is sent between client/server to cancel a file transfer. More...
 
class  PacketServerSuccess
 This packet is sent by server to client on success. More...
 
class  PacketCreateRoom
 This packet is sent by client to create a room. More...
 
class  PacketJoinRoom
 This packet is sent by client to join a room. More...
 
class  PacketLeaveRoom
 This packet is sent by client to leave its room. More...
 
class  PacketListRooms
 This packet is sent by client to request existing rooms list. More...
 
class  Packet
 A generic union type for packets. More...
 

Typedefs

typedef union Packet Packet
 

Functions

int receiveNextPacket (Socket socket, Packet *packet)
 Receives the next packet incoming on the given socket. More...
 
int sendPacket (Socket socket, Packet *packet)
 Sends the given packet on the given socket. More...
 

Variables

const union Packet NewPacketJoin
 
const union Packet NewPacketLeave
 
const union Packet NewPacketText
 
const union Packet NewPacketDefineUsername
 
const union Packet NewPacketServerErrorMessage
 
const union Packet NewPacketUsernameChanged
 
const union Packet NewPacketQuit
 
const union Packet NewPacketFileUploadRequest
 
const union Packet NewPacketFileDownloadRequest
 
const union Packet NewPacketFileUploadValidation
 
const union Packet NewPacketFileDownloadValidation
 
const union Packet NewPacketFileDataTransfer
 
const union Packet NewPacketFileTransferCancel
 
const union Packet NewPacketServerSuccess
 
const union Packet NewPacketCreateRoom
 
const union Packet NewPacketJoinRoom
 
const union Packet NewPacketLeaveRoom
 
const union Packet NewPacketListRooms
 

Detailed Description

Defines types of packets that are exchanged between client and server.

Function Documentation

◆ receiveNextPacket()

int receiveNextPacket ( Socket  socket,
Packet packet 
)

Receives the next packet incoming on the given socket.

Parameters
socketThe socket to receive the packet on
packetThe packet to fill in with received data
Returns
the number of bytes received (can be lower than or equal to 0)

◆ sendPacket()

int sendPacket ( Socket  socket,
Packet packet 
)

Sends the given packet on the given socket.

Parameters
socketThe socket to send the packet on
packetThe packet to send on the socket
Returns
the number of bytes sent (can le lower than or equal to 0)

Variable Documentation

◆ NewPacketCreateRoom

const union Packet NewPacketCreateRoom

This instance is used to create a new PacketCreateRoom

◆ NewPacketDefineUsername

const union Packet NewPacketDefineUsername

This instance is used create a new PacketDefineUsername

◆ NewPacketFileDataTransfer

const union Packet NewPacketFileDataTransfer

This instance is used to create a new PacketFileDataTransfer

◆ NewPacketFileDownloadRequest

const union Packet NewPacketFileDownloadRequest

This instance is used to create new PacketFileDownloadRequest

◆ NewPacketFileDownloadValidation

const union Packet NewPacketFileDownloadValidation

This instance is used to create new PacketFileDownloadValidation

◆ NewPacketFileTransferCancel

const union Packet NewPacketFileTransferCancel

This instance is used to create a new PacketFileTransferCancel

◆ NewPacketFileUploadRequest

const union Packet NewPacketFileUploadRequest

This instance is used to create a new PacketFileUploadRequest

◆ NewPacketFileUploadValidation

const union Packet NewPacketFileUploadValidation

This instance is used to create new PacketFileUploadValidation

◆ NewPacketJoin

const union Packet NewPacketJoin

This instance is used to create a new PacketJoin

◆ NewPacketJoinRoom

const union Packet NewPacketJoinRoom

This instance is used to create a new PacketJoinRoom

◆ NewPacketLeave

const union Packet NewPacketLeave

This instance is used to create a new PacketLeave

◆ NewPacketLeaveRoom

const union Packet NewPacketLeaveRoom

This instance is used to create a new PacketLeaveRoom

◆ NewPacketListRooms

const union Packet NewPacketListRooms

This instance is used to create a new PacketListRooms

◆ NewPacketQuit

const union Packet NewPacketQuit

This instance is ued to create a new PacketQuit

◆ NewPacketServerErrorMessage

const union Packet NewPacketServerErrorMessage

This instance is used to create a new PacketServerErrorMessage

◆ NewPacketServerSuccess

const union Packet NewPacketServerSuccess

This instance is used to create a new PacketServerSuccess

◆ NewPacketText

const union Packet NewPacketText

This instance is used to create a new PacketText

◆ NewPacketUsernameChanged

const union Packet NewPacketUsernameChanged

This instance is used to create a new PacketUsernameChanged