sityler
sityler

Reputation: 21

Real-Time Communication Between Linux Web Server and .NET Client Application

What I'm Trying To Do

Develop a C# WPF Windows application that can send and receive data to other WPF applications using a central web server running CentOS 6 Linux with MySQL.

Also, if the server program could handle requests from a mobile app (Android app to server - server to WPF client & vice-versa) as well as WPF clients, that would be highly preferable, but not necessary.


Example

Server (server in Texas)

Admin Client (user in California)

Client 2 (user in Florida)

Client 3 (user in New York)

  1. I send a "hello" broadcast from my computer, Admin Client, to Server.

  2. Server receives message and broadcasts "hello" to all listening clients.

  3. Client 2 and Client 3 show "hello" on their clients and respond "hey!"

  4. Server receives "hey!" messages and sends both to Admin Client.

  5. I send a message "open sesame" that executes RunOnMagicWord() method only on Client 2's application, and does nothing to Client 3.

  6. Client2 runs RunOnMagicWord() and sends "done!" message to server after method executes.

  7. Server receives "done!" message and sends to Admin Client.


What I've Looked Into

I'd prefer to keep everything in C# .NET including the server-side program, so that data sent between clients and to the server can be serialized easily. SignalR seems to be closest to what I'm looking for, but it seems to me it only works with IIS and not Apache/Linux. I don't have the option of switching to IIS, and it also feels like I may be over-complicating the whole thing, so...


My Question

Am I headed down the right path looking at using something like SignalR? If so, how do I get it to run on my CentOS server? Or is there a simpler way altogether of a Linux/MySQL server providing this kind of functionality to .NET applications?


Edit: Added other things I tried, reformatted paragraphs, added additional restrictions I have with this project in response to a comment

Upvotes: 2

Views: 1905

Answers (1)

Hrvoje Hudo
Hrvoje Hudo

Reputation: 9024

Everything you mentioned could work. But decision of what you should use can be driven by business requirements and constraints:

  • signalr and websockets are not reliable delivery mechanism. Messages can be lost. Use this for client notifications, something with low risk if the message is not delivered
  • web services (rest or soap) are synchronous, and also point-to-point. What if one side is not responding? WebApi with Rest would be easiest to implement, and would work cross-platform. Its easy to make PHP talk to .NET, just document and share your message schema
  • message brokers like RabbitMq, MSMQ, Azure Service Bus / Queues are async and reliable, but little bit more complex to implement. You get proper resiliency, and delivery confirmation.

For this kind of chat functionality, SignalR and mono .net app on linux should work fine. Also, Signalr is not the only option here, you have many websockets implementations for .net, like https://github.com/StackExchange/NetGain

Upvotes: 5

Related Questions