Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get custom protocol response

I was learning about custom protocols for few days, and there's one thing that I don't understand. I know how to start an app with custom protocol, but My question is,
Is it possible to get apps response and print it in Web Browser using javascript?
For example If I will send request to protocol myapp:// , that will open an app written in C#, and that app will return string "This is response" can to print it in Web Browser?
If so, can you help me to accomplish it?
Thanks in advance.

like image 788
René Beneš Avatar asked Nov 13 '12 21:11

René Beneš


People also ask

What is custom protocol handler?

- LS. Method of allowing a webpage to handle a given protocol using navigator. registerProtocolHandler . This allows certain URLs to be opened by a given web application, for example mailto: addresses can be opened by a webmail client.

What is custom protocol?

A custom protocol can be assigned the same name as a pre-defined protocol, in order to extend the number of IP addresses or ports associated with the original protocol. See Adding to a pre-defined protocol for more information.

What is a protocol handler windows?

Protocol handlers give the Windows Search indexer access to data stores, enabling the indexer to crawl the nodes of a data store and extract relevant information to index. Windows Search, for example, ships with protocol handlers for file system stores and for some versions of both Microsoft Outlook data stores.


1 Answers

Internet protocols aren't all about browsers.

mailto: causes an action in an email program (e.g. start a new email)

ftp: causes an action in an FTP program (which might be integrated into a web browser or Windows Explorer)

gopher: (well, that's not really prevalent anymore)

myapp:// will cause your (C#) app to start running. At that point, it can do anything a C# app can do. One thing it could choose to do is create a .html file on disk, and use

Process.Start("file://Path/To/My.html")

to cause the default web browser to open the document it just created.

UPDATE

You can certainly have your myapp:// protocol handler send an update to the web server that hosts the page in question. My assumption here is that the myapp:// handler is running on a client machine, and there is a web server on a different URL http://mydomain.com serving a page that includes a myapp:// reference.

  1. Web server renders a page that includes both a myapp:// URL and Ajax code to periodically query the web server for updates to part of the HTML body.
  2. User clicks the myapp:// URL
  3. Protocol handler runs
  4. Protocol handler sends an update to the web server, e.g. http://mydomain.com?user=joe&result=123
  5. Web server uses ?user=joe&result=123 to update response next time the Ajax callback is initiated
  6. Ajax callback gets updated data for page from web server, updates page.
like image 121
Eric J. Avatar answered Sep 29 '22 03:09

Eric J.