42 lines
911 B
C
42 lines
911 B
C
#define MESSAGE_LENGTH 256
|
|
#define COMMAND_LENGTH 16
|
|
|
|
#define HEARTBEAT_INTERVAL 3 // in seconds
|
|
#define HEARTBEAT_TIMEOUT 10
|
|
|
|
typedef enum {
|
|
Message = 1,
|
|
Login,
|
|
Logout,
|
|
Hearbeat,
|
|
List,
|
|
JoinGroup,
|
|
LeaveGroup,
|
|
Mute,
|
|
Unmute,
|
|
Signal,
|
|
Inbox
|
|
} Command_t;
|
|
|
|
typedef enum {
|
|
ACK_ACCEPTED = 0,
|
|
ACK_DELIVERED,
|
|
ERR_UNKNOWN_COMMAND,
|
|
ERR_NOT_LOGGED_IN,
|
|
ERR_ALREADY_LOGGED_IN,
|
|
ERR_ALREADY_IN_GROUP,
|
|
ERR_NOT_FOUND,
|
|
ERR_ALREADY_MUTED,
|
|
ERR_INVALID_FORMAT
|
|
} Signal_t;
|
|
|
|
typedef struct {
|
|
Command_t mtype;
|
|
Signal_t stype; // Used with mtype = signal. Responses from the server - to
|
|
// specify errors or acks
|
|
char sender[COMMAND_LENGTH]; // Who sent the message
|
|
char command[COMMAND_LENGTH]; // Functions as an attribute to mtype -
|
|
// nicknames, id to send/mute to
|
|
char message[MESSAGE_LENGTH]; // Actual message content
|
|
} msgbuf_t;
|