|
Hi.
I wrote a program with C# and use TAPI.My program dial a number and play a wave file for listener.
I use a event handler for managing call state:
m_CTapi.CallStateEvent += new CTapi.CallStateEventHandler(MyCallStateEventHandler);
public void MyCallStateEventHandler(Object sender, CTapi.CallStateEventArgs e)
{
switch ( e.CallState )
{
case CTapi.LineCallState.LINECALLSTATE_CONNECTED:
lsb_CallStatus.Items.Add("Call Connected...");
break;
case CTapi.LineCallState.LINECALLSTATE_DISCONNECTED:
lsb_CallStatus.Items.Add("Call Disconnected...");
break;
case CTapi.LineCallState.LINECALLSTATE_ONHOLD:
lsb_CallStatus.Items.Add("Call Hold...");
break;
case CTapi.LineCallState.LINECALLSTATE_IDLE:
lsb_CallStatus.Items.Add("Call Idle...");
break;
case CTapi.LineCallState.LINECALLSTATE_PROCEEDING:
lsb_CallStatus.Items.Add("Call in Progress...");
break;
case CTapi.LineCallState.LINECALLSTATE_OFFERING:
lsb_CallStatus.Items.Add("Call Offering...");
break;
case CTapi.LineCallState.LINECALLSTATE_ACCEPTED:
lsb_CallStatus.Items.Add("Call Accepted...");
break;
case CTapi.LineCallState.LINECALLSTATE_DIALING:
lsb_CallStatus.Items.Add("Call Dialing...");
break;
case CTapi.LineCallState.LINECALLSTATE_RINGBACK:
lsb_CallStatus.Items.Add("Call Ringback...");
break;
case CTapi.LineCallState.LINECALLSTATE_BUSY:
lsb_CallStatus.Items.Add("Call Busy...");
break;
case CTapi.LineCallState.LINECALLSTATE_SPECIALINFO:
lsb_CallStatus.Items.Add("Call Special Info...");
break;
case CTapi.LineCallState.LINECALLSTATE_DIALTONE:
lsb_CallStatus.Items.Add("Dial Tone...");
break;
}
}
Now my problem:when program dial a number and receive the first telephone ring,MyCallStateEventHandler receive 'Connected' event but I need to understand when a person pick up the phone(and he is listening)????how can I do this?
It's wonderful that these call states never happened:
LINECALLSTATE_ONHOLD,LINECALLSTATE_ACCEPTED,LINECALLSTATE_OFFERING,LINECALLSTATE_RINGBACK,LINECALLSTATE_BUSY,LINECALLSTATE_SPECIALINFO,LINECALLSTATE_DIALTONE
please help me to solve my problem.
best regards
|
|
|
|
|
HojatAlizadehfard wrote: I wrote a program with C# and use TAPI.My program dial a number and play a wave file for listener.
Good! I'm glad you made it!! So, which approach did you choose to send the audio? Please don't forget to tell me, I'm interested in this point.
HojatAlizadehfard wrote: m_CTapi.CallStateEvent += new CTapi.CallStateEventHandler(MyCallStateEventHandler);
I don't know why did choose to handle that event yourself, but here is my approach:
TAPIClass tapi;
ITAddress address;
ITBasicCallControl TheCall;
((ITAddress2)address).set_EventFilter(TAPI_EVENT.TE_CALLNOTIFICATION, 0, true);
((ITAddress2)address).set_EventFilter(TAPI_EVENT.TE_CALLMEDIA, 0, true);
tapi.ITTAPIEventNotification_Event_Event += new ITTAPIEventNotification_EventEventHandler(tapi_ITTAPIEventNotification_Event_Event);
int test = tapi.RegisterCallNotifications(address, true, true, TapiConstants.TAPIMEDIATYPE_DATAMODEM, 1);
void tapi_ITTAPIEventNotification_Event_Event(TAPI_EVENT TapiEvent, object pEvent)
{
switch (TapiEvent)
{
case TAPI_EVENT.TE_CALLNOTIFICATION:
{
TheCall = (ITBasicCallControl)(((ITCallNotificationEvent)pEvent).Call);
DialogResult res = MessageBox.Show("Answer?", "Incoming", MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
TheCall.Answer();
else
TheCall.Disconnect(DISCONNECT_CODE.DC_REJECTED);
break;
}
case TAPI_EVENT.TE_CALLMEDIA:
{
if (((ITCallMediaEvent)pEvent).Cause == CALL_MEDIA_EVENT_CAUSE.CMC_LOCAL_REQUEST
|| ((ITCallMediaEvent)pEvent).Cause == CALL_MEDIA_EVENT_CAUSE.CMC_REMOTE_REQUEST)
{
MessageBox.Show("data");
}
break;
}
}
}
Sorry, my application is about data calls so, it might look a bit different. My point is I use TAPI_EVENT.TE_CALLNOTIFICATION call notification event instead of Call state.
Tell me if it worked, if not, I'll try to look up more.
Regards
|
|
|
|
|
Greetings:
What is the accepted method used for forms and/or background processes to communication with one another asynchronously under C#.
For example, I have written my share of Windows apps under C++ and MFC that involve handling serial ports, USB ports or other such external sources. My usual approach is to monitor the port with a worker thread for incoming data. I might have a display window in the application that simply waits for incoming messages which can come in at any time without prompting. I usually create some sort of messaging structure and pass messages from the monitoring thread to the window using PostMessage. For those not familiar, PostMessage simply puts the message into the message queue and does NOT wait for a response or any indication that the message was received. This is in contrast to SendMessage, which waits for the message to be handled and is therefore not much different from calling the handler directly.
So I am looking for a means to do something similar under C# and .NET.
How is this accomplished in general?
Thank you in advance to anyone who responds.
Mark
|
|
|
|
|
|
Hello
Well, you can do almost the same with C# using SerialPort class, but for lpt, USB, and other ports or devices you have to do it this way:
1- Call API function CreateFile() with the port/device name.
2- Get the handle returned by that call and pass it to FileStream constructor
3- Use that FileStream object to read/write from/to the port/device.
I hope that was close enough.
Regards
|
|
|
|
|
Hi Nader, thanks for your response.
I guess the example I gave was a bit too specific. In general, I am looking for the general accepted way for threads and forms to send messages to each other asynchronously. For a more general example, Lets say there is a parent form that launches another form using "Show" so that the new form behaves like a modeless dialog. Now, the new form has controls of various stripes on it and the parent form need not know about everything that is going on on this form but needs to be notified of certain key events. And lets say that simply calling some member function of the parent form from the child form isn't quite going to work. In Win32 programming and MFC, we would send asynchronous messaged from one window to another using the messaging system built into windows. As long as your thread or window has a message pump, then it should get the message.
Is there anything like this for C#?
Regards,
Mark
|
|
|
|
|
Well, I think you are getting a little meticulous about details here . It's nice though not much seen these days.
Exchanging messages between forms has many forms , depending on your needs and design. There may not be a best practice that is considered an industrial standard or a windows logo criteria, rather it's just a mere advice that could be criticized by another programmer.
Jethro63 wrote: Now, the new form has controls of various stripes on it and the parent form need not know about everything that is going on on this form but needs to be notified of certain key events
Once I read that sentence I had the word interface jumping across my eyes. It would be a nice way to make a standard of communicaion between your parent form and different MDIChild types -ie. through a common interface-.
Jethro63 wrote: And lets say that simply calling some member function of the parent form from the child form isn't quite going to work
Well, actually it can be done using Parent.Invoke() method for events that you want your child form to wait for the parent to excute its code. If you want to fire an event in the parent form and not to wait until it's done, call Parent.BeginInvoke() instead. Both calls of course are from your child forms.
Jethro63 wrote: In Win32 programming and MFC, we would send asynchronous messaged from one window to another using the messaging system built into windows. As long as your thread or window has a message pump, then it should get the message.
Well, you still can use the same thing in C# if you like it. Actually the messaging system is still applicable -even in Windows Vista I think-, so simply:
1- In the child form call Windows API PostMessage() or SendMessage() functions -whichever suits you-, using P/Invoke and give it the handle of the parent form.
2- In the parent form implement IMessageFilter interface and use its PreFilterMessage() to catch your custom message or use any way that suits you -usually there are predefined handlers- to catch WM_ standard messages if you wish to send them.
Jethro63 wrote: Is there anything like this for C#?
In addition to the above there are more improvised ways like exchanging data between forms -considered as threads- using System.Runtime.Remoting.IPCChannel class, or even sockets -one form is listener and the other is client-, but I don't think they would be an interesting choice to you.
I hope that was useful.
Regards
|
|
|
|
|
Hi Nader:
Thanks for the advice. I am looking into Parent.BeginInvoke(), which I recognized in passing and will now take a closer look at.
Cheers,
Mark
|
|
|
|
|
Hello,
I have a problem with using the SmtpClient class in .net, It works fine when sending mails within the mail server (same domain). But as soon as i send to an external mail-address, i get the error: "Server Prohibited. We do not relay". Im not sure what to do here.
If you have any ide, please give me a tip.
Regards
Hmitosh
|
|
|
|
|
That's not a problem with the class, that is how your SMTP server is configured, as the message indicates.
led mike
|
|
|
|
|
Usually Most ISPs block using SMTP servers to send email other than their own SMTP Server. You should ask your ISP to get their SMTP Server, and if authentication required ...etc... information... After that, try with your ISP's SMTP server to send email. Hope that will work.
|
|
|
|
|
i want to assign multiple values to one key value eg.
a: 1,2,3,4
b:5,6,7,8
nd so on
what data structure shall i use as hash table is of no use in such situation
Bia
|
|
|
|
|
You can store your array of values in an ArrayList, and then store that in the Hashtable.
Ex:
Hashtable hashtable = new Hashtable ();
hashtable["a"] = new ArrayList (new Int32[] {1, 2, 3, 4});
hashtable["b"] = new ArrayList (new Int32[] {5, 6, 7, 8});
...
|
|
|
|
|
yeh we did that but how can we get the key by knowin the values is there any way??
cuz it alwaz givs us null
|
|
|
|
|
I suppose you'd have to iterate through each key and then use ArrayList.IndexOf() to see if your particular value was in that key's ArrayList.
|
|
|
|
|
yeh thanks i l try that
beu
|
|
|
|
|
Hi,
I have a web application wherein I need to call an outside DLL which executes a function call which is taking a lot of time. So what I need to do is that upon page_load of the application, I spwan a new thread which will call that function in the DLL and start initializing it.
Now, when the user actually goes to the page and requests another function from the same DLL, the 2nd thread which has been spun earlier would have almost done with initialization or getting it to completion. So this main thread should then wait for the 2nd thread to complete its initialization task at hand and when its done, it should take over from that and do normal web page and code processing further.
How do I do this? Which Threading methods do i use ?
Pls guide me as I am totally new to multi threading.
Thanks
Omkar
|
|
|
|
|
Hello
Revise WaitHandle class in your MSDN.
Regards
|
|
|
|
|
Hai,
I am Balu using ie5 browser using this browser popupwindow is opening fine but the same popup is not at all opening in the mozilla firefox browser is there any condition for browser compatability? can any body help for this situation.
regards,
Balu.A
|
|
|
|
|
Some browsers prevent popups depending on the security level of the browser Firefox is a good example. It's a settings issue.
Regards
|
|
|
|
|
Hi there,
Does anybody know a possibility to read the Video and Audiostream of a network and write it into an avi file in realtime using C# ? Audio and Video Streams must be multiplexed from different sources from the network.
It would be great if anybody knows a solution how to do that. If it is possible please insert also links or something else.
Thx!
|
|
|
|
|
hi,
i was wondering, im making an app in vs2005, but when its ready how am i going to convert it so it is an .exe istead of always opening and debugging vs2005
thx
|
|
|
|
|
It already is, open your project directory and take a look in the bin\Debug or bin\Release folders. Note if you want the release version then select the solution node in the Solution Explorer Pane and change Active Config to Release .
Just Google it.
Failing that try phoning
|
|
|
|
|
Hello!
I have been trying to use some of the examples on sorting columns in listviews that are published on for example http://www.codeproject.com/cs/miscctrl/ListViewColumnSorter.asp[^]and some other places but I keep getting this error:
Error 1 Using the generic type 'System.Collections.Generic.IComparer<t>' requires '1' type arguments
I guess it something that has changed with later versions of C# and I wonder if anyone knows how to solve this?
Best regards,
Hampus
|
|
|
|
|
You need provide a generic type argument for your IComparer, e.g.
IComparer<int> comparer = new MyIntComparer(); The <int> bit is the bit you seem to be missing, note this is just an example.
Just Google it.
Failing that try phoning
|
|
|
|