How can I send a push event via webrick? At certain timings, I want ruby to fire some events and send it to the browser via webrick. I can embed some JavaScript code on the page in advance.
Particularly, I am trying to implement one of the techniques written under HTTP server push and Pushlet on this wikipedia page.
Sawa.
If you want to send some messages to your clients, try Juggernaut2.
Of course, you'll need to start separate node.js-based server to send notifications, but Juggernaut2 works with RoR really well.
Good luck.
Related
I created a Slack app that sends a series of interactive messages to a channel. In my Slack API dashboard, I see that I can create and remove hooks. Right now the hook url that I have set up in my code is the one for the Slackbot channel.
But the problem is that such a message only gets sent to me.
I want to send the Slackbot messages to Alice in situation A, and to Bob in situation B. Not just to myself, the guy who configured the app.
What's the best way to do this?
I would suggest that you should not use hooks for this. A more sane way to do this right would be via chat.postMessage Web API method which is documented here!
This is because hooks are tied to specific conversations and that approach quickly hits a wall on what it can really achieve, especially messaging different people. Once you start using the web API it's pretty simple. Just ask for the scope during app installation (remember to add that scope in your dashboard), subscribe to the event in your API dashboard and then you are good to go.
Everytime you send a message via that method, Slack will send you a payload which you can use for testing and logging etc.
You can see all the different ways to message programmatically inside Slack here.
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 have an application which allow an user to send a lot of SMS to his contacts (like thousands).
Obviously that tasks can take a lot of time to complete.
So the idea is to display a progress bar on the client side, to indicate the user how many messages have been sent so far.
The back end of my app is a restful spring webservice.
The front end is done with ReactJS and Redux.
The question is:
Is it technically possible from the back end to periodically push data to the client, to update the progress bar, with the amount of messages already sent.
First question regarding the back end architecture:
I've seen that using JAX-RS 2 with spring, I can make asynchronous call in the back end, to execute other tasks(like querying the DB to see the messages already sent) while the other process is sending all messages. Am i looking in the right direction here ?
Second question regarding front end :
So far I use thunk functions for my requests(post/get) to the server, which returns a json response, and it works well. But in this case, the back end would periodically push data to the client side, until the main task is completed, so I don't understand how would that work out exactly ?
I guess I'm not gonna be able to achieve that using the same request ? Should I look at other technologies to achieve that ?
Please let me know, if the description of my problem is not clear.
Cheers
There are two options: you can keep track of the task on the backend and have an API endpoint to check the status and poll it every x seconds.
The other option would be to use sockets, the frontend client would listen for an event and update display onEvent. The backend would be responsible for emitting events.
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 am working on a Sinatra web app that needs to save any email that it receives in a db (or do something else as soon as a mail is received). What is the best tool for this job? I was looking at eventmachine and it seems a bit complex. I was considering the mail gem but it doesn't trigger events when mail is recieved. One final query: To test such an app, do I need it to host it online? If not, then how to do I send emails to the app and test?
Thanks a lot,
So Sinatra is a web server. Email doesn't come in from HTTP requests, so you need a mail server to receive the emails and assuming you still want to handle them in your Sinatra app, fire a request at your app.
check out http://steve.dynedge.co.uk/2010/09/07/incoming-email-in-rails-3-choosing-the-right-approach/ for a few options (it's thinking rails, but you should be able to translate)