0

Possible Duplicate:
how to get variable in desktop c# program from web javascript application

met a problem that there are two applications. one is desktop application in c#, and another is web application in javascript. some variables or informations in running desktop application are needed to transfer to web application. Does any one know how to solve this? Does any one would like to provide more details to solve this?

message queue(MSMQ) may solve, I may try. and database. which one could have better real time effect? WCF may solve, but it's complicated than those ways. If anyone have codes for this WCF to bridge the connection between windows program and web script, may send to me?

I am also thinking that if there are any physical buffer which could be used by c# windows and javascript. but javascript seems can not access physical buffer.

Community
  • 1
  • 1
bird_yin
  • 1
  • 2

1 Answers1

0

You could just use HTTP, starting a very simple HTTP server in your desktop C# app listening on 127.0.0.1 on any known but unused port and respond to get requests sending JSON or such.

Strictly speaking, you do not even have to parse requests, if they are all the same, you can just have TCP server and send a HTTP header and your data to any TCP client that connects.

yes, desktop c# can initiate tcp and http, also socket communication to web server. then, how web-based javascript receive packet sent by desktop c#. because web-based javascript needs the data and process.

In your desktop app you use HttpListener (not HttpClient) to do something like this and in web app refer to something like http://localhost:1234/customerData or whatever. If you want your data only on page load, you can pass valid .js with all the values and include it in the page, if you want something more dynamic, there are things like jQuery.

Eugene Ryabtsev
  • 2,232
  • 1
  • 23
  • 37
  • realtime effect is more important needed, do you think your suggested way can realize better realtime effect? – bird_yin May 18 '12 at 09:50
  • jQuery should be ok down to 1 second intervals. If you need it faster, consider using WebSocket instead of HTTP to transmit the data (general idea stays the same). [Here](http://stackoverflow.com/questions/2211898/c-sharp-web-socket-server) people use it for a task similar to yours. – Eugene Ryabtsev May 18 '12 at 11:13
  • the data from desktop is sensors data, so realtime effect can not be seconds intervals, if so, delay shows a little bit big. How do you think of real time performance of using WebSocket? – bird_yin May 18 '12 at 13:56
  • I guess you have to test it to be sure, but **well** below 100ms in any case, so no human operator would see a delay, that is certain. – Eugene Ryabtsev May 18 '12 at 16:30