Windows Mobile 6 answer multiple calls - c#

I develop a Windows Mobile 6 application where I have to manage multiple calls, using c++ TAPI (from C# using PInvoke).
The application works fine for a single call, but I do not know how to manage when I have an incoming call and I want to answer the second incoming call.
For example: I answer the first call with lineAnswer, I detect the second call and I want to accept it with lineAccept, then put the first call on hold lineHold and answer the second call with lineAnswer.
The problem is that I cannot manage at all the second call.
What steps (function calls) should I follow to manage 2 incoming calls?

Have you looked at the OpenNetCF.Telephony library? It's an open source C# wrapper around the TAPI functions, and it comes with a number of samples that show how to monitor and answer incoming calls. Maybe there are some pointers for you in there on how to handle your specific scenario.

I found myself the solution:
The command placed for the call is still lineAnswer but before, out application must be the owner of the call, so a I use lineSetCallPrivilege with the Owner value.

Related

Best way to implement Twilio conference timeout? (Second participant never picks up)

We are using Twilio's conference call for creating calls between 2 or more parties.
https://www.twilio.com/docs/voice/tutorials/how-to-create-conference-calls
When a caller(A) calls Twilio number a conference is created on the server using C# Rest API and we then add the caller(A) to a conference. Using the conference statuscallback when caller(A) joins conference we then call other parties using the Conference.ParticipantResource.Create() method and a foreach loop to call a group of people whos role is labeled ADMIN (Could be from 1 to 9 parties) with a timeout of 30 seconds and a statuscallback.
How do I determine if no one answers the call via statuscallback after say 35 seconds?
I would like to send caller(A) to a voicemail if no one picks up. But the problem Im have is that the callback fires after each called ADMIN dont answer or rejects the call. I know this is by design but Im curious to know how to know when all callers (Admins) didnt pick up the call and send original caller to voicemail. And if one admin picks up to stop calling other admins.
Hopefully someone can help. Thanks in advance.
Hi Twilio Evangelist here,
Sorry that you're having trouble building the conference line in a way that suits your needs. Twilio does not have a feature that will maintain the state of different callers being added to a conference line.
I would suggest the following.
Create a collection that represents the list of your admins (and the application should have a way to update a single admin's state for when they've been contacted).
As you go about contacting the admins, you'll want to update state as the app attempts to reach them. This way you can respond to a person picking up the phone or alternatively redirecting to voicemail accordingly within your code. This will also make it easy to know when your code has attempted to call everyone.
If no one picks up, then you'll be able to redirect your original caller accordingly by modifying their call in-progress (which you can do with this tutorial here).
Let me know if you run into any issues.

How to approach removing needless instantiation when calling native method from WebAPI

I have a dotnet core WebAPI web server that needs to execute a native method written in Win32 C++. The problem is, each time this method is called it needs to instantiate a bunch of things before it can do what it needs to do, this adds delays to the request. (It's currently using DLLImport to access the C++ method in the compiled DLL).
What I would like to do is have some sort of long running process start when the server starts, which will handle the initialization once, then have my WebAPI service call a method inside this process that executes the code that I actually need to run immediately, without the need to initialize its dependencies each time. Since this is a web server, the process will need to be able to handle multiple requests at once.
What is the recommended approach for this? I have full access to the C++ code and the WebAPI server code so I'm free to do whatever needs to be done to accomplish this.
You may set-up some IPC infrastructure between the two.
One way to do it would be to make your DLL COM compatible. I.e having the DLL be a COM server to some COM class. The server process would then 'CreateInstance' a class, which will automatically launch your native process. A call would then just be a normal function call, COM will handle the RPC.
Another simpler way will be using a named memory-mapped file. Both processes will open a handle to this, there you can store a queue or some data structure. The server process will push while the native process will pop. You can use windows events to synchronize this. You can write this yourself or use something like boost::interprocess for the C++ part. I assume there may be other IPC libraries you may find for this.
You can also use a Pipe, I know C# has some easy ways to handle windows pipes. Pipes do not need synchronization but to efficiently handle a number of such requests you may need a number of threads on the native process to read from the pipe.
Personally i'd go with using COM if that is possible. As it will hide for you the low-level IPC stuff that may be a pit-fall. It is a bit longer to set-up though.

c# Should I use a service or just poll the database

I don't know too much about services so if I am trying to do something they are not intended for please forgive me.
I am trying to wright dispatching software for a family member. They plan on starting with 3 or 4 dispatchers but it may scale in the future. I need the software to constantly (every 5 or 10 seconds at the very least) check and see if a new unhandled call has been placed when not in a call or if they are in a call see if another dispatcher updated the call (due to a call in with additional information).
Which option would be better for the above scenario
A) Have a table in a database that tracks updates to calls/ new calls and poll it every 5 - 10 seconds from every instance of the software.
B) Have a service running on the machine that has the database and have that service take care of all SQL. Create an instance of each call in the service and then just ask the service if there are any changes or unhandled call.
If B, is it possible to create a delegate in the service that the software on another (networked) machine can subscribe to? If so where might I find information on doing that, I could not find anything on google.
This is kind to broad.
However, you can use the following
DB Trigger to watch for inserts ect, then do and fabulous db stuff when triggered.
Create a Windows Service that polls, thats not a problem at all.
You could even self host a WCF server with a Duplex Contract that other software subscribes to, you could then send notifications ect via that channel.
or use SignalR for notification which would work just fine in this situation as well, and is a 5 minute job to get working.
Though, there is lots of approaches here, You really need to do some research to find what suits you most
Solution B is better.
If B, is it possible to create a delegate in the service that the
software on another (networked) machine can subscribe to? If so where
might I find information on doing that, I could not find anything on
google.
It depends on your need and project type.
You can use SignalR in ASP.Net
If you work with sockets you can keep connection alive and store client context in a list and notify theme

Notify host of changes

I have an ASP.NET application and a C# application hosting a WebBrowser. The ASP.NET application is run through the C# application.
I am in need of notifying the C# application when e.g a button is clicked. The best approach will probably be through Javascript. This doesn't seem complicated as I can expose functions for the javascript window.external, but the only URL my C# application sees is the /Default.aspx. All the javascript functions (window.external.myfunc(..)) has to come from this page.
Any ideas? I'm turning up blank. I'm also a bit unsure on how to call the javascript functions from code-behind. ScriptManager.RegisterClientScriptBlock seems to be used a lot, but can this be called several times at one page?
Thanks!
By the way, for the C# client I'm using WebBrowser.ObjectForScripting to a custom object which will take these window.external function calls from Javscript. This works.
The part with ObjectForScripting and window.external will work fine.
And in order to call js functions from your ASP.NET code, you should use ajax calls from the js. There are two approaches for that:
1- create a web service and invoke it constantly to check for anything that has happened (i.e polling). this is the simplest way and can be easily implemented, for example using jQuery:
$.ajax(...);
then call your window.external.func() from the callback to that ajax call (of course if it's returned the intended value). Note that with this method, you will always have a delay because the client should poll the server.
2- make a connection to the server and keep it open, then send the data from the server when it's ready. For this matter, you can make use of something like SignalR. This will solve the issue of delay, but will keep an open connection which in turn brings other issues.
Actually the main factor to decide between these two methods is whether you are okay with a delay. If it's not the problem to wait for an average of 15 seconds, use the first method with a polling time of 30 seconds. If you want it to be real-time, use the second method but be cautious with its own issue like long-running connections, lack of session-state in SignalR and so on.
I just wanted to show you the choices. please tell me if it's unclear in any manner.

Best Practice: Converting an application to a service with a schedule

I'm a bit of a beginner as far as programming is concerned. And looking at stack overflow I haven't found anything that quite answers my question.
I have created a C# console application that is used to push an XML file to a web service that I don't control. It does this by creating an http webrequest. The service will probably be running on windows server 2008, or a win 7 varient. Development is done in VS 2010.
My end goal is to run this program twice a day with little user involement. And I was told that services were the best way to do this. I know that services do not take user input and that outputs are usually to a log file. My console app dosn't take user input but must have the ability to C.R.U.D. files. Beacuse it creates and then reads an XMl file into the web request. If needed I should have no problems having it write any errors to a log file, but at current though it creates/sends an error report via email.
I have 2 questions:
Question 1:
I would like this service to call the application every 12 hours, Is it more reliable/better practice to use a service to determine when to run the application? Or use windows' built in scheduler, or a .net solution like quark? I'm looking for reliability and also, little user involvement. Kind of a set and forget deal.
Question 2:
What would the suggested best practice be for converting my program?
INFO: I have previously created a empty windows service that I would like to fold my application into. (This was done via tutorial, the service contains all that is needed to for a service but it dosn't do anything... yet! OnStart, OnStop, installer etc.) What would be the best way to do it? Should I call my application inside the service's OnStart() method? Our should I add the application as a dll to the service. It's not that I don't think I could do it. It's just my searches on the matter seem to point out that it would be better to just start from a service and add some code to that. My goal would be to minimise the code needed to convert this application.
Thanks for all your help,
Chris
I like standalone programs run by the scheduler because they are easier to write and test.
Services would be more appropriate when they have to be running all the time...say to monitor something.
Question 1: Personally running twice a day seems like a scheduled task type of operation
Question 2: I'd describe it as: more or less put the body of static void Main(string[] args) into the OnStart method. Then also create a timer in OnStart which will call the trigger function in your class. But then I've only stumbled my way through writing windows services so I'm not 100% certain on this advice...
One consideration might be whats the risk of anything failing in the process? If there is a chance of an unhandled exception, the service will die and either would need special settings to restart it or complete error handling to be coded. Where a scheduled task will always automatically retry at the next trigger interval.

Categories

Resources