I have an infrastructure, bussiness rules and other logic, that I use in a WPF application, in it I have a messaging service that implements an message service interface, this service is register in a Container, I use Castle Windsor.
Every time that the infrastructure needs to show any kind of messages it uses this service and shows a message and waits for the reply, with this I don't have to a request to the GUI/WPF to show a message.
My problem is that I'm using this same infrastructure for a ASP.NET MVC site and I having some problems in find a solution where I can use this same interface. Basically if the message service has to show a messages it should be able to post a message box in the browser, preferably via AJAX and wait for the reply of the user and then continue the execution according to the answer.
I don't know if I'm made my self clear enough on the problem.
Any hints on how to implement such a service would be much appreciated.
Thanks.
The problem is the server knows nothing about open browsers, therefore it can't signal the broswer to show the message.
The solution would appear to be to queue messages from the service, have some script on the page that checks (using ajax) for items in the queue, and display messages as appropriate.
Related
I'm developing a project with Symfony 3.4.
I would like to send a message to all the clients currently viewing a page when something happens. I evaluated both Server-Sent Events and Websockets, and I decided to go with the former, because the communication is unidirectional (only server to client).
For this purpose, I'm using this library: https://packagist.org/packages/tonyhhyip/sse
It seems to work, but I need to specifically send a message when something happens in the whole system. I tried with the Symfony event system (by creating a custom event), but events seem to be dispatched and captured only within the same session (i.e., the same logged user). In other words, if an action performed by a user triggers an event, it is not captured by other users and therefore a message is not sent to the browser via SSE.
Any suggestion?
Thank you
I am quite new with Spring MVC and Web technologies.
I need "real time" interactions between the server side and the client side of my web application.
When a user click on a button, I want to execute server side code, create a message and send it to every client.
I think Web Sockets are the solution. I can add methods on the controller part of my application.
When a user click on a button, the Controller method is called. I can execute code and send back a message for every clients.
But now, I can receive messages coming from another website. Let's say that I am using a MessageListener.
How am I supposed to notify my clients? The server side of WebSockets is in the controller. I don't think i am supposed to call this method from the server.
I can create some kind of weird adapter capable to
- Establish WebSocket channel with server (a local channel)
- Receive messages from another website using a broker
- Send the message to the controller
I don't feel like this is an unusual need and my solution looks tricky.
I am sure there is an easier way to do it, but I am not able to find it.
So, am I doing it right? Do you have any idea, any suggestion?
Thank you for your help.
Ben
I have an ASP.NET Web API server, that have to communicate with different applications on different platforms. And now I want to create a method that would be something like a callback: client application subscribes to it and waits until server fires a message.
Example:
Many users are waiting until new product will be available in store - they subscribe to this "event". When product arrives in store - every customer receives a message, which have to be handled in some case.
Users send a request "Subscribe"
Server receive a request "Product available!"
Server sends every user a message with product details.
User's application processes the message
I tried to find some information about callbacks or duplex in ASP.NET Web API, but the one advice - it's better to use WCF for this approach.
Solutions
In every client application create something like timer, that every N seconds sends a request "Is product available?" until gets "false". When the response will be true - send a message "Get product details". It's causes a lot of traffic and if there will be many clients with these timers - it would be something bad, isn't it?
Create a small callbacks-server (maybe WCF). But in this case would be a lot of problems with communication between this server and apps on different platforms.
Maybe there are some solution in ASP.NET Web API, that i missed.
If you have some ideas how i can solve this problem, please give me an advice.
Thanks for help.
Looks like you want push notifications from your server - which, in this case, can be achieved by combining SignalR with Web API.
Brad Wilson has a great example on this:
code here - https://github.com/bradwilson/WebstackOfLove
NDC Oslo talk explaining all this - http://vimeo.com/43603472
In short, whenever you add new item to the Web API, you can notify all the connected (subscribed) clients:
public void PostNewItem(ToDoItem item)
{
lock (db)
{
// Add item to the database
db.Add(item);
// Notify the connected clients
Hub.Clients.processItem(item);
}
}
SignalR will invoke the processItem function on the client.
Alternatively, you might want to look into JavaScript SSE and Web API PushStreamContent but that is much more low level and SignalR abstracts a lot of this type of stuff for you so it might be more complicated to deal with.
I blogged about this approach here http://www.strathweb.com/2012/05/native-html5-push-notifications-with-asp-net-web-api-and-knockout-js/
I need your help to solve next issue: I am developing MVC application and want to send instant messages between users. This message will ne standard - it's like notification. I am thinking about two optins:
use XMPP protocot, but I don't need the huge amount of options it could provide, I need just basic functionality I've discribed;
have some static array in MVC application with users invitations were send to and ajax function which will call controller action, check if user is in static list. If yes - make message visible on the page. And plus do page autoupdate. But I am not sure about this becouse array will be called very often.
What do you think, guys? Do you have any ideas? I will be very thankfull for any help!
You may take a look at SignalR.
Also checkout Jabbr which is built on SignalR:
https://github.com/davidfowl/JabbR
This is a chat application written by the author of SignalR David Fowler.
You can set jquery timer to update messages with ajax. And when user writes message , it can be saved in Cache or in database if you want to save it permanently.
I have read the article about Push Notification Service, but I am still confused. I’m a new for MS window phone application developing. My application needs to get the data in the whole class from web service that is for the specific organization. Hope someone can answer my question as below.
In my application, the phone rings and the user answer the phone during sending the request to the web request to get the data. What will happen if the web service sending back the respond?
In the above situation, do I need the Application Push Notification service?
I retrieve the data by using DataContractSerializer. If I need the Push Notification Service, is it meaning that I need to modify the webservice for returning the xml instead of the whole class?
The ongoing call will not disrupt the web request-response flow hence you need not be troubled about it