Hi Friends I need help in coding..
Actually I am developing application for making call by soft phones.
In this i have fours ports means at a time i can make four calls.
Here I will get contacts number from webservices those numbers i need to put in Queue then have to check that 4 ports any atleast one port is free or not.. If free then one contact number have to pick from queue and make to dail again that keep on checking that amoung four ports any one port free then pass another number from queue.
Like this queue must be always watching that ports are free or not... if free then pass number from queue.
"Here after call ended automatically am changing port availability otherwise ports are busy like this status wil be keep on changing.. According to the status that queue must pass numbers....
Still not clear na Frown | :( .......
Trying to explain as much as possible you guys....
Sample code:
ThreadStart ts = new ThreadStart(severgetdata);
Thread serverthread = new Thread(ts);
Thread CurrentThread = serverthread;
serverthread.Start();
public void severgetdata()
{
byte[] bytes = new Byte[1048576];
IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
Socket listener = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
try
{
listener.Bind(localEndPoint);
listener.Listen(10);
while (true)
{
Console.WriteLine("Waiting for a connection...");
Socket handler = listener.Accept();
data = null;
while (true)
{
int bytesRec = handler.Receive(bytes);
data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
if (data.IndexOf("") > -1)
{
break;
}
}
Console.WriteLine("Text received : {0}", data);
byte[] msg = Encoding.ASCII.GetBytes(data);
handler.Send(msg);
string receivedata = data;
receivedata = receivedata.Remove(receivedata);
QueueCustomers(receivedata);
Checkports();
MakeCall();
handler.Shutdown(SocketShutdown.Both);
handler.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Console.WriteLine("\nPress ENTER to continue...");
Console.Read();
}
public void QueueCustomers(string receivedata)
{
callCustomer.contactnumber = receivedata;
CustomerQueue.Enqueue(callCustomer);
int count = CustomerQueue.Count;
}
Public void Checkports()
{
}
I added sample code here please go through it. I am planning like this to handle. Like this the queue must work on ports states.. I dont know how to make a queue continues to check the ports status.....
Thanks & Regards
S Chand Basha