Is it possible (and simple) for C# console to open a web socket with a browser, without using Node.js? Meaning, an active and opened C# console application, always running on the server, which can send and receive messages to and from the browser at real time.
I tried to use a browser loading the socket.io.js JS file (https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js), and creating a C# console application using TcpListener class. And there seems to be a successful connection. But I can't send messages between the server and the client.
Yes, I've done it several times.
C# console / Windows service: Use SignalR library. Should be able to get it via NuGet.
Web application: Use jquery.signalr-x.x.x.js library.
SignalR should primarily establish a WebSocket connection between the SignalR hub in our .NET app, and the jquery.signalr client library in your web application.
Related
I had created a chrome extension and a c# host application, the chrome app is sending events to the c# host application. But how we can receive the events in chrome from the host app.
I found a solution for this; a C# application can control the Chrome add-on using the native messaging and the pipe channel.
The pipe stream channel is connected between two C# apps and one end of the pipe is connected to the native messaging which is a channel for the browser and the C# app.
But my application is not completely ready. I'm working on it to get a reliable channel communication between these two channels.
as the question says, how can I communicate from a rest API to Windows application. I have Windows application that connects to a linux server over TCP connection. This application manages multiple connections (around 7-8k tcp connection on different ports and keeps alive these connections all the time.). I have a mobile application that connects to rest API (APS.net C#) and works as expected. Now i want to send some more information from linux server to mobile client. How can I send a request from rest API to windows application and get response to send it to mobile application when requested from mobile. This communication between API and Windows application should be asynchronous and could handle around 7-8k connections without delay. How can i achieve this? Is it possible to achieve this using current architecture? or should I change it? I am willing to adopt any proposed architecture or new framework and any other programming language which serves the purpose good. Here is rough structure.
I think you can try using SignalR, it allows for dual communication between client and serer
It uses websockets as its underlying connection and you can either send messages to all connected clients or a specific client.
https://dotnet.microsoft.com/apps/aspnet/signalr
i need help in reading clients Serial port (COM port) from my web application.
i am able to read it on windows application but if i wants to put it over the web.
is it possible to do so?
I could be wrong, but I don't think it's possible to read a serial port (or indeed any type of port) directly from the browser because there isn't going to be any interface to the underlying system hardware, etc.
However depending on what you need to do there are a couple of options (and probably more that I haven't thought of)
Browser plugin
You could write a browser plugin that can do whatever it wants (within the limitations of a browser plugin of course) and can be used by your webpage by injecting the serial data feed into the page.
The problem with this would maybe having to create plugins for all browsers (assuming you want the web application to run on whatever browser the user chose)
Self-hosted WebAPI in a desktop app
You could embed a self-hosted Web API into either your existing desktop app or a tray application / Windows service, etc, that interfaced with the serial port as you currently do.
This app or service would read the data and "publish" it via a simple JSON-based api that your web app can GET (or could use web sockets to push the data once the initial connection is made by the web app) and could also accept commands from the web browser via POST, etc.
Your web application could then access this via HTTP to get the data and do whatever it liked with it.
Either way, I think the user is going to have to install something to their local system for this to work.
We have a Website (hosted somewhere) and C# Application (which is installed on my PC). I need to accomplish the following:
Customers fill up the form on the website, i.e. the task is "created"
C# Application immediately receives this data from the website and process it
The result is sent back to the server, i.e. "task accomplished" message
The website updates status regarding this task
How do you build this kind of link between the website and an app?
In the past I've used TCPListener to communicate between two C# apps. I'm also familiar with the UDPlistener and such.. Will this knowledge be of some use? The website is going to be build on the PHP.
Some tips and advises are appreciated. Thanks.
Your website should not be dependant on an application running on your home or office PC, so the site should publish some kind of service or feed. You can make this a webservice, which is quite easy in PHP.
You then consume this service from your C# application. Make it request the new tasks regularly, by polling the service. When you've received new tasks you process them in your application, and when you've done what you want to do you update the tasks on your server using another webservice call.
All this can be done using some sort of queue in the database that backs your website.
Make the C# application a web service may be a windows host depending on your requirement
you can the webservice from php as shown here Using PHP to call a WCF web service with multiple bindings
If you have the control over your web host and your client, you could try setting up a WCF service with duplex contracts which allows the server to callback your client. Your PHP site can call the WCF service and it can in turn notify the client. Else you will have to go with the polling method where the Desktop client has to poll the web service to get the list of pending tasks.
I want to send data to a driver software via browser application with in same machine. If this driver can keep on listening to external connection via socket as a windows service, can I write a web application to send data to this driver by using php, applet or .net. Driver is written in C#. Is this possible and if so can someone show me a path/suggestions or any resource related to this?
I do not know a whole lot about drivers...
But, if you can self-host a WCF service in the C# driver, than you can do IPC (inter-process communication) on the same machine. The WCF could expose multiple endpoints ie.) http, namedpipe, or tcp and the .NET web application can subscribe to the service and send data to the C# driver.
Also, if you use a http or tcp endpoint, i believe that the web application would be able to connect to the C# driver from another machine.
WCF Reference: http://msdn.microsoft.com/en-us/library/ms731082.aspx
you could use web sockets WebSocket, however your driver would have to handle the handshake.