Twilio Click To Call 'no-answer' status in JavaScript client - c#

Is there any way to know if an outgoing call was not answered using only the Twilio Click To Call JavaScript client?
Twilio.Device.disconnect(function (conn) {
logAndDisplay('Call ended');
});
Checking conn.status() after a call was not answered is 'closed' (same as if a call was answered) so there is no way to figure out the difference.
Before the JavaScript disconnect callback is called the no-answer status can be retrieved on the server from DialCallStatus. In case that status is not available on the client, is there a way to send the server value and access it on the client?

In the end I could not find how to read a no-answer status on the client.
The (hacky) solution was to make an AJAX request to the server to get that status.

Related

What is the purpose of th HTTP GET method in forms?

As far as I understand, the GET method asks the server to send something to the client's browser. I set up a HTTPListener in C# and when I access http://localhost:1330/form.html the request I get from the client is: GET /form.html which means that the client is saying "Hey server, I need the HTML code to display that page in the browser", which makes sense.
If I set a <form> with method=POST in form.html, the input fields values are located in the request body which is in context.Request.InputStream in C# which looks similar to this: input_name1=value&input_name2=value2&input_name3=value3... and the URL remains /form.html.
This also makes sense. The client says: "Hey server, take this data that was written in the HTML <input> elements" and the server uses it, maybe storing it in a database or computing something and send it back to the client.
Now if I set the form method to GET, the URL is modified to: /form.html?input_name1=value&input_name2=value2&input_name3=value3 and the context.Request.InputStream remains blank which is the opposite of the POST, in which the InputStream contained the data and the URL had no queries. For me, the GET method in forms doesn't make any sense. Why do we need to get the data from the form client side, send it to the server and then getting it back to client unmodified? Why do I send the data from the browser to C# and then sending it back to browser, if I can just get it client side using simple JavaScript?
In the moment the browser makes the GET request with the queries to the server, the client browser already has that data, so why does it ask the server to give it if it is already at the client's browser?
Generally speaking, an HTTP GET method is used to receive data from the server, while an HTTP POST is used to modify data or add data to a resource.
For example, think about a search form. There may be some fields on the form used to filter the results, such as SearchTerm, Start/EndDate, Category, Location, IsActive, etc, etc. You're requesting the results from the server, but not modifying any of the data. Those fields will be added to the GET request by the client so the server can filter and return the results you requested.
From the MDN article Sending form data:
Each time you want to reach a resource on the Web, the browser sends a
request to a URL. An HTTP request consists of two parts: a header that
contains a set of global metadata about the browser's capabilities,
and a body that can contain information necessary for the server to
process the specific request.
GET requests do not have a request body, so the parameters are added to the URL (this is defined in the HTTP spec, if you're interested).
The GET method is the method used by the browser to ask the server to
send back a given resource: "Hey server, I want to get this resource."
In this case, the browser sends an empty body. Because the body is
empty, if a form is sent using this method the data sent to the server
is appended to the URL.
An HTTP POST method uses the request body to add the parameters. Typically in a POST you will be adding a resource, or modifying an existing resource.
The POST method is a little different. It's the method the browser
uses to talk to the server when asking for a response that takes into
account the data provided in the body of the HTTP request: "Hey
server, take a look at this data and send me back an appropriate
result." If a form is sent using this method, the data is appended to
the body of the HTTP request.
There are plenty of resources online to learn about the HTTP protocol and HTTP verbs/methods. The MDN articles An overview of HTTP, Sending form data, and HTTP request methods should provide some good introductory reading material.

Displaying Missed Calls In Twilio Call log

I am implementing voice call feature using Twilio SDK in one of my application. I don't know how can I get the missed call logs in Twilio.
I am calling from my mobile to Twilio number. As soon as the client started ringing I have disconnected the call from my mobile and wanted to show that as Missed call in my call logs.
here the issue I am having is when I want to display the "missed call" it's not working. I see the call statuses but it seems like almost every call is being marked as "completed"
How can I get missed calls in Twilio call log
Please help if anyone had done this.
When you dile add two parameters
'action'=> "www:yourwebsite.com/your/url"
'method' => "GET"
This will submit a Get request to "www:yourwebsite.com/your/url"
if ($request->DialCallStatus == 'no-answer')
{
Call status = "You Missed a call from" . $request->number;
}

Sending Http requests from a webbrowser to HttpListener

I've set up an HttpListener running on port 8086 on my custom server application, which works with JSON and XML over sockets. I can't change my server application to any other implementation, I am stuck with it for now.
I'm a bit new to Http, so feel free to correct my naviety below! I've searched, but can't find anything that deals with my exact problem.
When I use Hurl.it to send an HttpRequest to the server, the GetContext function fires no problem and I am able to send an html response back to Hurl.it.
Now, the question is, I want to be able to send out Reset Password email links in the form of "http://myip:PORT/resetpasswordseed=74283235" and have a browser be able to receive, parse and display a dynamically generated html form. (I will also need to add SSL to this a bit later, as I don't want a newly updated password being sent as plain text in a URL.)
Now, when I click the URL link http://myserverip:port/resetpassword with Edge or Firefox the GetContext function does not fire and the web browser times out. Have I missed something or am I trying to do something that is not possible? I don't get an error message or an exception or anything.
Any help would be appreciated.
Cheers
Craig.

Send message to sender of SignalR request

Can you with SignalR send information the client who has send the request? Here I've quickly draw the current situation with paint:
The client send a SignalR request to the server with
meldingenHub.server.vote();
and the server send a message back to all the clients with
Clients.All.SendOke();
The situation I will have is that only the sender of that request, receive the message I send form the server. All the other clients don't receive that message. Is there something I can use like this:
Clients.Sender.SendOke();
When the Server method is invoked, there is a Context object populated with the details of who called the method. There is a property in here called ConnectionId which has the identifier of the caller.
So to invoke a method only on the sender's client, simply call:
await Clients.Client(Context.ConnectionId).SendAsync("ClientMetodName");
What you need to do is send the connection id of the sender to the hub and then use Clients.Client(connId).broadcastMessage(....) see THIS other answer for an example.

how to call javascript function at backend in asp.net?

If I want to call a javascript function after some code has been run in backend, how to do that? I don't want to add onclientclick event in frontend. I need to run the frontend function after a certain backend code has been run. Thanks in advance.
The best bet is to use Page.RegisterStartupScriptBlock.
When you submit to the server, the server is going to process your request and any other event / code that is required. It will then send back to the client the response.
If you want a user to invoke an action / event (say a button click), have it hit the server and then do some Java Script action after that please look at the following posts:
http://forums.asp.net/t/1003608.aspx/1
http://wiki.asp.net/page.aspx/1574/differences-between-registerclientscriptblock-amp-registerstartupscript-and-how-they-work-with-ajax-update-panel/
http://www.codeproject.com/KB/aspnet/ClientServer.aspx
The way (I) would do this is to refactor my code so that the code behind is called from a jQuery post to an ashx code file.
then on return of that function i can run whatever I like.
If you want details, let me know.
However, if this is not useable, then you could either place a property in your aspx page;
public string Action { get; set; }
then in your html;
var action = '<%= this. Action %>';
and perform an action.
Or you might set a hidden field to a value and check against that.
edit
this largely depends on when in the life cycle the code behind is being run. On ajax postback, on initial execution? When?
Client Script in ASP.NET Web Pages is the MSDN reference that you probably want.
The best way i can think of to do this is with web sockets. There are a few c# web socket implimentations around, such as Nugget. This allows you to open a socket with your client and allows for the possibility of the server proactively contacting and sending data to the client. There are other techniques to have the server talk to the client such as long polling. This way you can have the server call the client once something has happened on the server.

Categories