How to handle clients connections from RabitMQ server application - c#

I'm trying to implement an application server just like a chat server using rabbitMq.
Clients connect directly to the rabbit server. the application server should be able to know which clients have been connected and when a client disconnects an event should be fired in the application server.
Is it possible to implement this kind of functionality with Rabbitmq?
Does Rabbitmq have any kind of event dispatching for connection events?(not for clients but for my application server)
I'm using official C# client for Rabbitmq.

As #Lutz Horn already said, you can use the event exchange plugin to emit events related to connections, channels and much more.
Reference: https://www.rabbitmq.com/event-exchange.html
GitHub: https://github.com/rabbitmq/rabbitmq-event-exchange
You have to create a queue, so that the event exchange routes these events to this queue. And have a consumer that listens to this queue. I have added a link to the one that I am using.
Code: https://gist.github.com/sathishbabu96/35821a6b1e90daa76d3dd76bef084788

Related

PHP server to communicate with WPF application by sockets

I'm trying to create PHP server to communicate with multiple WPF applications (c#), I want it similar to signalR working, where client will subscribe and server broadcast the updates to all clients subscribe with the server.
Please suggest how to start this, I have WPF application running, I need to create the PHP server, i think socket will be used here, as client application will be running all the time and listening to any update from the server.
Any Hint is appreciable.
As you guessed you need to implement sockets to enable communication between your server and the clients. Find a explanation and code example in this youtube video (C#). For the beginning this should help you with your server (php) implementation.
Typically the server is listening for incoming connections and will then deal with them (like it is explained in the video). As I do not know enough of your environment I suggest two options:
One: You make your clients listen for incoming connections. In reference to the video you need to switch the implementations of the server and client socket. For establishing a connection between the server and the client the server needs an address which is normally the ip address.
Two: You can use the typical approach and let the server listen for connections. To imitate the function of the server pushing to the client, you could use a timer at client site and recurringly ask the server for an update. This approch is handy in the case that you can not address your clients from the server as you may not know their ip address for example.
You may want to improve your performance with threading. Find further information here

Notification Service in C#

I am going to design a notification service which is supposed to do the following:
Clients call notification service at startup with initial data (client ip, client id).
The server saves clients in connected clients list using their IPs.
If one client needs to notify (send message to) other clients, it calls a method on the notification service to publish this message to other clients using their IPs.
On client shutdown, the service removes this client from connected clients list.
My Question is:
1- Is this an applicable design for such a notification service?
2- I know that connections between service and client can be implemented using WCF callbacks, Microsoft Message Queue and Sockets. Is there any other technology / method that can be used in c#?
Note:
Now, clients are .net c# applications, but in the future clients may contain mobile applications, so i need a method that is platform independent.
Thank you

How can I get my app to listen for Incoming SMS messages?

I have a windows form App which is written to send and recieve texts, this is implemented by sending a message via .NET Remoting to a Service installed on a server, which has a GSM modem (dongle) connected to it, the service then sends the message through the GSM modem once it has a message from the Client App.
Everything's going well so far with regards to sending a text, However we need functionality to enable the reading of incoming text messages; I'm unsure how to go about writing my code to listen out for incoming texts, and then send them over to my Client App.
Could anyone give me some pointers on where to start please? I've tried MSDN Documentation on the TcpClientChannel Classes, but this doesn't prove useful for listening to the COM port or anything like that.
If you are using the AT command set then I'm afraid your server will have to poll the dongle's SIM for messages at an interval (whatever makes sense).
In terms or notifying the client you can either:
follow the same scheme as the server and poll regularly
-or-
if the remoting connection is open continuously, have the server notify using an event on one of your remoting objects. The event args for this event can contain all of the new messages.

ASP.NET & TCP Server Solution

My server has two applications running on it:
TCP socket server that continuously accepts and sends messages to and
from clients (C# .NET Winforms)
ASP.NET application
What I need is:
When a message is received from a client via the TCP connection (app 1) I want the ASP .NET application (app 2) to reflect this data dynamically. I realise that I can set database entries via the TCP socket, which will then be picked up by the ASP.NET application.
A way of sending messages to clients from the ASP .NET application to clients that are available inside of the TCP socket server
e.g. A simple chat program where a client sends “Hi” and server responds “Welcome”. The ASP .NET should show a log of this conversation as it happens. Immediately. And if I click a button on the ASP application, it should send a message on behalf of the socket server to the client “You have been accepted onto the server”
For the most part, the messages are going to be fairly short like the ones shown here.
What is the best way to do A and B?
SignlaR is a good solution if you're getting the messages from another SignalR client (web page).
But what if these messages are being sent from a 3rd system over TCP/IP?
Then you need to open a TCP port in the ASP.NET Web Application and after receiving a message you have to push it to the web clients.
But the question is, what is the best way to have such a TCP Listener hosted in a Web Application (ASP.NET)?
if your "messages" are mostly textual, you may want to take a look at SignalR.
SignalR is a new library for asp.net to enable real-time web functionality.
It uses websockets (or long polling if websockets is unavailable at server/client).
It has support for different client types.

Client Server 24/7 Listner

We want to implement a client server application. here is the scenario.
Server listens for client 24/7.
Server accept request for client and save it in DB for further process.
Once processing is done (it may take few hours), Server will response back to client.
in short , client and server listens for each other 24/7.
I want to implement it in C# but i also want that it should be accessibly from all platforms.
Also is it possible in WCF?
I agree with Yuck, this is a basic WCF scenario. There a few articles, videos and tutorials to get you started here http://msdn.microsoft.com/en-us/netframework/dd939784

Categories