so I'm in a little project of mine and for now the client gets some information it needs using requests, more precisely requesting the data to a nodejs server running express. The thing is I want that when 1 client alters something every connected client gets a notification that something just changed. How could I do this? I'm new to all this networking stuff so any help is appreciated.
Also the client is a C# Windows Forms
This sounds like it can be achieved via the publisher-subscriber design pattern. Where each client will subscribe to an event and listen to it (perform an action on it) whenever there's an event being broadcasted. I suggest you take a look at the pattern and see how others have implemented it particularly to your situation.
You can take a look at Socket.io which is "a library that enables real-time, bidirectional and event-based communication between the browser and the server."
Related
I'm trying to create a tool for the QA team.
One of the features I'd like to add is a webhook for some events (sent as JSONs when some actions are taken).
AFAIK, in C# .NET Core v2.2, this feature is mostly implemented using the HttpListener class.
What I'd like to do is to run my simple Listener class/function in a parallel thread to the main program so events can be processed while the rest of the solution is active (it serves as an API to query DB).
My question is how to implement this.
my question mainly focus on how to run the listener on a background thread during app start - not on implementation of the connection.
The "Startup" is where I'd try to add it but I'm not sure how.
I found the services part (AddService, AddSingleton...) But couldn't find anything specific. Am I on the right track?
I didn't paste any code as the implementation is irrelevant (I guess) but will upload the Listener should anyone ask.
Is this existing in a Web app, or a Console App?
You might have a much easier time piggybacking on SignalR if you want to send Server->Client style events in json
https://learn.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-5.0
Pretty easy to setup and get running, you can have clients subscribe to listen to an API end point and then bind to events to fire off functions when they get pinged from the server.
I want to implement a feature like, if anything has been updated on Server-side like in database(the change can be from a client or another resource), then an event should be triggered and i come to know what change has been made. Then, through a rest api, i will send the response to UI with an event code, message and the new data from database.
And on UI, i have the approach to handle the events.
Please, tell me the approach or study material to implement this feature.
To use bi-directional communication between the clients and server you can use one of the following frameworks depending on your requirments:
SignalR
WebAPI and WebSockets
Socket IO (framework for Node.js)
Alchemy-Websockets
Fleck
SocketCluster (framework for Node.js)
I am using C# ASP.NET MVC 4 Razor
I have a Grid in ASP.NET MVC Razor View that displays the user records. Is there any way to show the new users in Grid without sending the async request to server after each 1 min ?
I searched on Google a lot. Now, finally I am posting the query here to get any clue for this solution to avoid Traffic on Server. As this page will be visible to at least 20,000 users
#Christos approach is the right one!, Just to add more info about it for an ASP.NET solution I would it use SignalR, that lets you implement a simple server/client communication and it's cross browser (it has several polyfills that if it cannot use web sockets it will use server-sent event, and so on), and the best part is that you don't need to worry about that implementation.
Once your clients are connected to the signalR server you can notify them everytime you need to add a new item to the grid.
http://www.asp.net/signalr/overview/getting-started/tutorial-server-broadcast-with-signalr
I hope it helps!
You could make use of the the publish/subscriber pattern. This can be done using for instance a redis server.
In software architecture, publish–subscribe is a messaging pattern
where senders of messages, called publishers, do not program the
messages to be sent directly to specific receivers, called
subscribers. Instead, published messages are characterized into
classes, without knowledge of what, if any, subscribers there may be.
Similarly, subscribers express interest in one or more classes, and
only receive messages that are of interest, without knowledge of what,
if any, publishers there are.
Please have a look here.
Doing so, the first time a client requests data from the server will subscribe to the server for taking any updates. Once any update arrives, the server will push the update to the clients that have subscribed, without requiring from the client to make any other request to the server.
As for implementation details, please have a look here.
I'm designing a Client/Server App in C# where all the Model Object and calculation has to be done on the server. The server doesn't need a specific UI.
Meanwhile I'd like my clients to be able to execute different functions or services from the server and receive the result of the computation from it as well as binding or subscribing to some values and each time the server update it, it sends the update to all clients who subscribed to this value.
Nothing spectacular in this I think.
I dont have any background in Network or Server-Client apps.
My question is the following:
I'd like to bind directly properties of my ViewModel which is Server side to the View which is Client Side.
Is there a way for me to do this like if the view was in a normal local MVVM framework?
I'd like to avoid having to create a specific language between the clients and the server and having then to handle the queue and priorities of clients messages.
If not, would you have some readings to recommend ?
Many Thanks.
You don't want your views to rely on a network connection to stay responsive, even if you solve the technical challenges of what you are proposing. Networking should be done in a way that can fail gracefully.
This is bad and you should not do it. That's my opinion.
Additionally, you really shouldn't be designing your own protocol for communication. You could use something like WCF or another framework that allows you to just call a remote function.
This is the scenario.
I have multiple clients on our application, and one server.
The server is itself disconnected from the clients, it just downloads some data from the web via a windows service (web services and FTP), processes the data and updates a database to which all the clients are connected and draw data from.
I would like to be able to actively notify the clients, and with a certain degree of granularity, when some downloading occurs (i.e. only the Traders when a price/trade update occurs, or only the Engineers when there's something for them) without polling.
The server should fire up a notification to all the connected clients instead of having them continuously "ask" if there is an update, because in this case I would have to maintain state on all the clients.
I thought about XMPP, with Matrix.
To do so each client has to open a persistent connection with the windows service, but I lack the exact details on how to implement this. MAybe with nodes!
For what I understand XMPP is perfect for what I want to accomplish and gives me the extensibility to grow to some more functionality if I have the need to.
I don't know if to implement my own server or use one of the existing one (I hear jabberd2 has an excellent windows server).
But most important: I need suggestions on A) an XMPP server to run on Windows and B) a C# library. Besides Matrix I have found very few, and above all I need notifications support (pubsub).
For simplicity, I'd consider using a WCF service that implements a long polling technique. This article gives some details on scaling the WCF service efficiently.
For notifications that there is new data in the database, if you are using SQL Server, try SqlDependency. It allows you to set up an event that fires in your code whenever the result of a given query changes. I've used it effectively for just this sort of thing.