Xeno-rat
Loading...
Searching...
No Matches
xeno_rat_server.Forms.Live_Microphone Class Reference
Inheritance diagram for xeno_rat_server.Forms.Live_Microphone:
Collaboration diagram for xeno_rat_server.Forms.Live_Microphone:

Public Member Functions

 Live_Microphone (Node _client)
 
async Task RecvThread ()
 Asynchronously receives data from MicNode and adds audio to the player if playing.
 
void TempOnDisconnect (Node node)
 Disconnects the client and microphone node if they match the provided node, and closes the form if it is not disposed.
 
async Task RefreshMics ()
 Asynchronously refreshes the list of microphones and updates the UI components accordingly.
 
async Task< string[]> GetMicroPhones ()
 Asynchronously retrieves the list of microphones available from the client and returns the result.
 
async Task SetMicroPhone (int index)
 Sets the microphone using the specified index.
 

Protected Member Functions

override void OnFormClosing (FormClosingEventArgs e)
 Releases the unmanaged resources used by the Form and its components when the form is closing.
 
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 task by creating a mic node, adding temporary on disconnect, refreshing microphones, and starting the receive thread.
 
async Task< NodeCreateMicNode ()
 Creates a MicNode and returns it. If MicNode already exists, returns the existing MicNode.
 
void Live_Microphone_Load (object sender, EventArgs e)
 Event handler for the form load event.
 
async void button2_Click (object sender, EventArgs e)
 Starts the player and sends a signal to the client to start playing.
 
async void button3_Click (object sender, EventArgs e)
 Handles the click event for button3, stopping the player and sending a stop signal to the client.
 
async void button1_Click (object sender, EventArgs e)
 Asynchronously refreshes the microphones and updates the UI.
 
async void comboBox1_SelectedIndexChanged (object sender, EventArgs e)
 Handles the SelectedIndexChanged event of comboBox1.
 
void InitializeComponent ()
 Initializes the components of the form including the combo box, labels, and buttons.
 

Private Attributes

Node client
 
Node MicNode
 
AudioPlayer player = new AudioPlayer(new WaveFormat(44100, 16, 2))
 
string[] MicroPhones
 
bool playing = false
 
System.ComponentModel.IContainer components = null
 Required designer variable.
 
System.Windows.Forms.ComboBox comboBox1
 
System.Windows.Forms.Label label1
 
System.Windows.Forms.Button button1
 
System.Windows.Forms.Button button2
 
System.Windows.Forms.Button button3
 

Constructor & Destructor Documentation

◆ Live_Microphone()

xeno_rat_server.Forms.Live_Microphone.Live_Microphone ( Node _client)
inline
Here is the call graph for this function:

Member Function Documentation

◆ button1_Click()

async void xeno_rat_server.Forms.Live_Microphone.button1_Click ( object sender,
EventArgs e )
inlineprivate

Asynchronously refreshes the microphones and updates the UI.

This method triggers the asynchronous refresh of the available microphones and updates the user interface accordingly.

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

◆ button2_Click()

async void xeno_rat_server.Forms.Live_Microphone.button2_Click ( object sender,
EventArgs e )
inlineprivate

Starts the player and sends a signal to the client to start playing.

This method enables the start button, disables the stop and pause buttons, starts the player, and sends a signal to the client to start playing.

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

◆ button3_Click()

async void xeno_rat_server.Forms.Live_Microphone.button3_Click ( object sender,
EventArgs e )
inlineprivate

Handles the click event for button3, stopping the player and sending a stop signal to the client.

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

This method disables button3 and enables button2 and button1. It stops the player and sends a stop signal to the client using asynchronous communication.

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

◆ comboBox1_SelectedIndexChanged()

async void xeno_rat_server.Forms.Live_Microphone.comboBox1_SelectedIndexChanged ( object sender,
EventArgs e )
inlineprivate

Handles the SelectedIndexChanged event of comboBox1.

Parameters
senderThe source of the event.
eThe EventArgs that contains the event data.

This method sets the microphone based on the selected index in comboBox1. If the selected index is not -1, it calls the SetMicroPhone method asynchronously and awaits its completion.

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

◆ CreateMicNode()

async Task< Node > xeno_rat_server.Forms.Live_Microphone.CreateMicNode ( )
inlineprivate

Creates a MicNode and returns it. If MicNode already exists, returns the existing MicNode.

Returns
The created or existing MicNode.
Exceptions
ExceptionThrown when an error occurs during the creation of MicNode.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose()

override void xeno_rat_server.Forms.Live_Microphone.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 releases all resources held by any managed objects that this Component references. This method is called by the public Dispose() method and the Finalize method.

◆ GetMicroPhones()

async Task< string[]> xeno_rat_server.Forms.Live_Microphone.GetMicroPhones ( )
inline

Asynchronously retrieves the list of microphones available from the client and returns the result.

Returns
An array of strings containing the list of available microphones.

This method sends an opcode to the client to request the list of microphones, receives the number of microphones available, and then retrieves the names of the microphones one by one. The retrieved microphone names are stored in an array and assigned to the MicroPhones property of the class.

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

◆ InitializeAsync()

async Task xeno_rat_server.Forms.Live_Microphone.InitializeAsync ( )
inlineprivate

Initializes the asynchronous task by creating a mic node, adding temporary on disconnect, refreshing microphones, and starting the receive thread.

Returns
An asynchronous task representing the initialization process.

This method initializes the asynchronous task by performing the following steps:

  1. Creates a mic node by awaiting the result of the CreateMicNode method.
  2. Adds temporary on disconnect by invoking the AddTempOnDisconnect method of the mic node.
  3. Refreshes microphones by awaiting the result of the RefreshMics method.
  4. Starts the receive thread by invoking the RecvThread method.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeComponent()

void xeno_rat_server.Forms.Live_Microphone.InitializeComponent ( )
inlineprivate

Initializes the components of the form including the combo box, labels, and buttons.

This method initializes the components of the form including the combo box, labels, and buttons. It sets up the properties and event handlers for the form controls such as combo box, labels, and buttons.

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

◆ Live_Microphone_Load()

void xeno_rat_server.Forms.Live_Microphone.Live_Microphone_Load ( object sender,
EventArgs e )
inlineprivate

Event handler for the form load event.

Parameters
senderThe object that raised the event.
eThe event data.
Here is the caller graph for this function:

◆ OnFormClosing()

override void xeno_rat_server.Forms.Live_Microphone.OnFormClosing ( FormClosingEventArgs e)
inlineprotected

Releases the unmanaged resources used by the Form and its components when the form is closing.

Parameters
eA FormClosingEventArgs that contains the event data.

This method disposes the player object, releasing any unmanaged resources used by the player.

Here is the call graph for this function:

◆ RecvThread()

async Task xeno_rat_server.Forms.Live_Microphone.RecvThread ( )
inline

Asynchronously receives data from MicNode and adds audio to the player if playing.

This method continuously receives data from MicNode while it is connected. If the received data is null, the method breaks the loop. If the player is in the playing state, the received audio data is added to the player.

Exceptions
InvalidOperationExceptionThrown when the MicNode is not connected.
Returns
A task representing the asynchronous operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshMics()

async Task xeno_rat_server.Forms.Live_Microphone.RefreshMics ( )
inline

Asynchronously refreshes the list of microphones and updates the UI components accordingly.

This method retrieves the list of available microphones using the GetMicroPhones method and updates the items in the comboBox1 accordingly. If the list of microphones is empty, it disables the button2. Otherwise, it enables the button and sets the first microphone using the SetMicroPhone method.

Exceptions
ExceptionThrown when an error occurs while retrieving the list of microphones.
Returns
A task representing the asynchronous operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMicroPhone()

async Task xeno_rat_server.Forms.Live_Microphone.SetMicroPhone ( int index)
inline

Sets the microphone using the specified index.

Parameters
indexThe index of the microphone to be set.
Returns
A Task representing the asynchronous operation.

This method sends a byte array opcode with a value of 2 to the client asynchronously using client.SendAsync(byte[]). Then it sends the index converted to bytes to the client asynchronously using client.SendAsync(byte[]).

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

◆ TempOnDisconnect()

void xeno_rat_server.Forms.Live_Microphone.TempOnDisconnect ( Node node)
inline

Disconnects the client and microphone node if they match the provided node, and closes the form if it is not disposed.

Parameters
nodeThe node to be compared with the client and microphone node.

If the provided node matches the client or the microphone node (if not null), this method disconnects them. If the form is not disposed, it is closed using a method invocation.

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

Member Data Documentation

◆ button1

System.Windows.Forms.Button xeno_rat_server.Forms.Live_Microphone.button1
private

◆ button2

System.Windows.Forms.Button xeno_rat_server.Forms.Live_Microphone.button2
private

◆ button3

System.Windows.Forms.Button xeno_rat_server.Forms.Live_Microphone.button3
private

◆ client

Node xeno_rat_server.Forms.Live_Microphone.client
private

◆ comboBox1

System.Windows.Forms.ComboBox xeno_rat_server.Forms.Live_Microphone.comboBox1
private

◆ components

System.ComponentModel.IContainer xeno_rat_server.Forms.Live_Microphone.components = null
private

Required designer variable.

◆ label1

System.Windows.Forms.Label xeno_rat_server.Forms.Live_Microphone.label1
private

◆ MicNode

Node xeno_rat_server.Forms.Live_Microphone.MicNode
private

◆ MicroPhones

string [] xeno_rat_server.Forms.Live_Microphone.MicroPhones
private

◆ player

AudioPlayer xeno_rat_server.Forms.Live_Microphone.player = new AudioPlayer(new WaveFormat(44100, 16, 2))
private

◆ playing

bool xeno_rat_server.Forms.Live_Microphone.playing = false
private

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