Xeno-rat
Loading...
Searching...
No Matches
Chat.ChatForm Class Reference
Inheritance diagram for Chat.ChatForm:
Collaboration diagram for Chat.ChatForm:

Public Member Functions

 ChatForm (Node _server)
 
async Task Heartbeat ()
 Waits for the heartbeat from the server and disconnects if not received within a specified time.
 
async Task RecvThread ()
 Asynchronously receives data from the server and updates the UI with the received message.
 

Protected Member Functions

override void Dispose (bool disposing)
 Releases the unmanaged resources used by the component and optionally releases the managed resources.
 

Private Member Functions

async Task InitializeAsync ()
 Initializes the asynchronous operations by calling the Heartbeat method and awaiting the RecvThread method.
 
async void button1_Click (object sender, EventArgs e)
 Sends the input message to the server and updates the UI with the sent message.
 
void textBox2_KeyDown (object sender, KeyEventArgs e)
 Handles the KeyDown event for textBox2 and performs a click on button1 when the Enter key is pressed.
 
void textBox2_TextChanged (object sender, EventArgs e)
 Event handler for the TextChanged event of textBox2.
 
void ChatForm_Load (object sender, EventArgs e)
 Activates the chat form when it is loaded.
 
void InitializeComponent ()
 Initializes the components of the ChatForm, including text boxes and buttons.
 

Private Attributes

Node server
 
bool recived_heartbeat
 
System.ComponentModel.IContainer components = null
 Required designer variable.
 
System.Windows.Forms.TextBox textBox1
 
System.Windows.Forms.TextBox textBox2
 
System.Windows.Forms.Button button1
 

Constructor & Destructor Documentation

◆ ChatForm()

Chat.ChatForm.ChatForm ( Node _server)
inline
Here is the call graph for this function:

Member Function Documentation

◆ button1_Click()

async void Chat.ChatForm.button1_Click ( object sender,
EventArgs e )
inlineprivate

Sends the input message to the server and updates the UI with the sent message.

Parameters
senderThe object that raised the event.
eThe event data.

This method sends the input message to the server using asynchronous communication and updates the UI with the sent message. It clears the input text box after sending the message and scrolls the chat box to the latest message.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChatForm_Load()

void Chat.ChatForm.ChatForm_Load ( object sender,
EventArgs e )
inlineprivate

Activates the chat form when it is loaded.

This method is triggered when the chat form is loaded. It ensures that the chat form is activated and brought to the front.

Here is the caller graph for this function:

◆ Dispose()

override void Chat.ChatForm.Dispose ( bool disposing)
inlineprotected

Releases the unmanaged resources used by the component and optionally releases the managed resources.

Parameters
disposingTrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the component and optionally releases the managed resources. If disposing is true, this method disposes of the managed resources. If disposing is false, this method does not dispose of the managed resources.

◆ Heartbeat()

async Task Chat.ChatForm.Heartbeat ( )
inline

Waits for the heartbeat from the server and disconnects if not received within a specified time.

This method continuously checks for the heartbeat from the server while it is connected. If the heartbeat is not received within 5 seconds, the server is disconnected.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeAsync()

async Task Chat.ChatForm.InitializeAsync ( )
inlineprivate

Initializes the asynchronous operations by calling the Heartbeat method and awaiting the RecvThread method.

This method first calls the Heartbeat method to perform a heartbeat operation. Then, it awaits the RecvThread method to handle receiving data asynchronously.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeComponent()

void Chat.ChatForm.InitializeComponent ( )
inlineprivate

Initializes the components of the ChatForm, including text boxes and buttons.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecvThread()

async Task Chat.ChatForm.RecvThread ( )
inline

Asynchronously receives data from the server and updates the UI with the received message.

This method continuously receives data from the server while the server is connected. If the received data is a single byte with value 4, it sets the recived_heartbeat flag to true and continues to receive more data. If the received data is not a heartbeat, it decodes the data to a UTF-8 string and appends it to the UI element textBox1 with "Admin: " prefix. After updating the UI, it scrolls to the end of the text and continues to receive more data. Once the server connection is closed, it prints "end!" to the console and closes the UI if it is not already disposed.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textBox2_KeyDown()

void Chat.ChatForm.textBox2_KeyDown ( object sender,
KeyEventArgs e )
inlineprivate

Handles the KeyDown event for textBox2 and performs a click on button1 when the Enter key is pressed.

Parameters
senderThe object that raised the event.
eA KeyEventArgs that contains the event data.

This method checks if the Enter key is pressed and then simulates a click on button1. It also handles the event by setting e.Handled and e.SuppressKeyPress to true to prevent further processing of the key event.

Here is the caller graph for this function:

◆ textBox2_TextChanged()

void Chat.ChatForm.textBox2_TextChanged ( object sender,
EventArgs e )
inlineprivate

Event handler for the TextChanged event of textBox2.

Parameters
senderThe object that raised the event.
eThe event arguments.

This method is called when the text in textBox2 is changed. It can be used to perform actions based on the changed text.

Here is the caller graph for this function:

Member Data Documentation

◆ button1

System.Windows.Forms.Button Chat.ChatForm.button1
private

◆ components

System.ComponentModel.IContainer Chat.ChatForm.components = null
private

Required designer variable.

◆ recived_heartbeat

bool Chat.ChatForm.recived_heartbeat
private

◆ server

Node Chat.ChatForm.server
private

◆ textBox1

System.Windows.Forms.TextBox Chat.ChatForm.textBox1
private

◆ textBox2

System.Windows.Forms.TextBox Chat.ChatForm.textBox2
private

The documentation for this class was generated from the following files: