C-chat
Functions
ui.h File Reference

API to communicate with user. More...

Go to the source code of this file.

Functions

void ui_init ()
 Initialize required resources for UI.
 
void ui_cleanUp ()
 Free allocated resources for UI.
 
void ui_reset ()
 Reset UI state. More...
 
void ui_getUserInput (const char *prompt, char *buffer, int buffer_size)
 Get the entered message by the user. More...
 
void ui_messageReceived (const char *sender, const char *message)
 Displays the given message from the given sender to the user. More...
 
void ui_informationMessage (const char *message)
 Displays an information message to client. More...
 
void ui_errorMessage (const char *message)
 Displays an error message to the client. More...
 
void ui_joinMessage (const char *username)
 Displays a join message to the client. More...
 
void ui_leaveMessage (const char *username)
 Displays a leave message to the client. More...
 
void ui_welcomeMessage ()
 Displays welcome message to the client.
 
void ui_usernameChanged (const char *oldUsername, const char *newUsername)
 Tells the client an user changed its username. More...
 
void ui_successMessage (const char *message)
 Displays a success message to the client. More...
 

Detailed Description

API to communicate with user.

This adds an abstraction between main program logic and the way messages are displayed to client.

Function Documentation

◆ ui_errorMessage()

void ui_errorMessage ( const char *  message)

Displays an error message to the client.

Parameters
messageThe error message to display to the client

◆ ui_getUserInput()

void ui_getUserInput ( const char *  prompt,
char *  buffer,
int  buffer_size 
)

Get the entered message by the user.

The user input returned in buffer does not contain an ending carriage return.

Parameters
promptPrompt message
bufferContains the entered message
buffer_sizeThe size for the given buffer

◆ ui_informationMessage()

void ui_informationMessage ( const char *  message)

Displays an information message to client.

Parameters
messageThe information message to display to client

◆ ui_joinMessage()

void ui_joinMessage ( const char *  username)

Displays a join message to the client.

Parameters
usernameThe username of the client who joined

◆ ui_leaveMessage()

void ui_leaveMessage ( const char *  username)

Displays a leave message to the client.

Parameters
usernameThe username of the client who left

◆ ui_messageReceived()

void ui_messageReceived ( const char *  sender,
const char *  message 
)

Displays the given message from the given sender to the user.

Parameters
senderThe sender name to display
messageThe message to display to client

◆ ui_reset()

void ui_reset ( )

Reset UI state.

To be called in case of ui_getUserInput getting interrupted.

◆ ui_successMessage()

void ui_successMessage ( const char *  message)

Displays a success message to the client.

Parameters
messageThe message to display

◆ ui_usernameChanged()

void ui_usernameChanged ( const char *  oldUsername,
const char *  newUsername 
)

Tells the client an user changed its username.

Parameters
oldUsernameThe old username of the user
newUsernameThe new username of the user