Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Voice and Text Conferencing Library

5.00/5 (12 votes)
15 Feb 2010CPOL4 min read 64.6K   14.9K  
A library for creating a voice and text conferencing application
ConferenceServer

ConferenceClient

Introduction

This Library was a part of my final year project. I have searched a lot on the web related to voice conferencing in C# but I couldn't find anything useful so I decided to modify peer to peer voice chat code that I found on CodeProject named “A Voice Chat Application in C#” into Voice conferencing. It also contains Text Conferencing feature that helps programmers to build conferencing software.

Voice Conferencing is based on client server architecture. Voice Conferencing Server uses two servers one for managing client (e.g. adding and removing client) and the other to handle communication. Voice Conferencing Client also uses two clients, one for entry and exit and the other for communication. Text Conferencing also uses client/server architecture. Text Conferencing server utilizes one TCP Server and Text Conferencing Client is based on a TCP client.

The main feature of this Conferencing Library is that it provides the complete implementation of conferencing work. Programmers just have to use its predefined methods and events in their code.

Using the Code

Voice Conferencing

VoiceConferencingServer class handles all work related to Voice Chat at the server side. Its constructor takes three arguments:

C#
public VoiceConferencingServer(String Name,int HandlingPort,int CommunicationPort)
  1. Server Name (String)
  2. Handling Port (this port is used for handling Clients entry and exit in Voice Chat Server)
  3. Communication Port (all the voice communication is done through this port)

VoiceConferencingServer class contains two events related to User Handling and four methods related to voice conferencing.

C#
interface VoiceConferencingServer {                  
       //User Handling Events             
       event VoiceChatServer.UserAddedEventHandler ClientAdded;                 
       event VoiceChatServer.UserRemovedEventHandler ClientRemoved;
       //Methods    
       void InitializeCall(object sender);   
       void UninitializeCall(); void Mute(); 
       void Unmute(); 
       }

ClientAdded Event is raised when a new Client is logged into the voice server. It uses UserArgs class as argument.

ClientRemoved Event is raised when a new Client is logged out to the voice server. It uses UserArgs class as argument.

InitializeCall Method takes one argument “Form control”. This method starts both the user handling and voice communication server.

UninitializeCall Method disposes servers and terminates all communication between client and server.

Mute Method is used to mute server voice.

Unmute Method is used to unmute server voice.

VoiceConferencingClient class handles all work related to Voice conferencing on client side. Its constructor takes four arguments:

C#
public VoiceConferencingClient
	(String _ServerIP,String Name,int HandlingPort,int CommuncationPort)
  1. _ServerIP (Server IP Address)
  2. Name (Client Name)
  3. Handling Port (this port is used for handling logged in and logged out process in VoiceConferencingClient)
  4. Communication Port (All the voice communication is done through this port)

VoiceConferencingClient class contains four methods related to voice conferencing.

C#
interface VoiceConferencingClient { 
          void InitializeCall(object sender);     
          void UninitializeCall(); 
          void Mute(); 
          void Unmute(); 
          }

InitializeCall Method connects to server and starts voice conferencing between client and server.

UninitializeCall Method disposes clients and terminates all communication between client and server.

Mute Method is used to mute client voice.

Unmute Method is used to unmute client voice.

Text Conferencing

TextConferencingServer class handles all work related to Text conferencing on server side. Its constructor takes two arguments:

C#
public TextConferencingServer(int Port,String Name)
  1. Port (it is used to handle conferencing work)
  2. Name (Server Name)

TextConferencingServer class contains three events and two methods:

C#
interface ITextConferencingServer{  
       //Events                  
       event TextConferencingServer.ClientAddedEventHandler ClientAdded;           
       event TextConferencingServer.ClientRemovedEventHandler ClientRemoved;
       event TextConferencingServer.MessageEventHandler MessageRecieved;
       //Methods      
       void SendMessage(string mess, string reciever);
       void BroadcastMessage(byte[] message);
       }

ClientAdded Event is raised when a new Client is logged into the voice server. It uses UserArgs class as argument.

ClientRemoved Event is raised when a new Client is logged out to the voice server. It uses UserArgs class as argument.

MessageRecieved Event is raised when message is received on server. It uses MessageArgs class as argument.

SendMessage Method takes two arguments, one message that you want to send and second client name to whom you want to send.

BroadcastMessage Method takes one argument message that you want to broadcast to all connected users.

TextConferencingClient class handles all works related to Text conferencing on client side. Its constructor takes two arguments:

C#
public TextConferencingClient(String ServIP,int Port, String Name)
  1. ServIP (Server IP Address)
  2. Port (it is used to handle conferencing work)
  3. Name (Client Name, it should be unique)

TextConferencingClient class contains three events and one method.

C#
interface ITextConferencingClient{ 
          //Events 
          event TextConferencingClient.MessageEventHandler MessageRecieved; 
          event TextConferencingClient.UserAddedEventHandler UserAdded;
          event TextConferencingClient.UserRemovedEventHandler UserRemoved;
          //Methods
          void sendMessage(string message, string Reciever);
          }

ClientAdded Event is raised when a new Client is logged in to the voice server. It uses UserArgs class as argument.

ClientRemoved Event is raised when a new Client is logged out to the voice server. It uses UserArgs class as argument.

MessageRecieved Event is raised when message is received on server. It uses MessageArgs class as argument.

SendMessage Method takes two arguments, one message that you want to send and second client name to whom you want to send.

Prerequisite

You need to have DirectX installed in your PC, because this library use DirectX to capture sound and you also have to add DirectX’s DLL in your project. You can download it from Microsoft’s website.

References

  1. Voice Chat Application in C#
  2. Chat Application Using Asynchronous UDP sockets

Future Work

I am working on webcam conferencing and Remote Desktop and I hope it will be on CodeProject very soon.

History

  • 15th February, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)