dwyl / hapi-socketio-redis-chat-example Goto Github PK
View Code? Open in Web Editor NEW:speech_balloon: Real-time Chat using Hapi.js + Socket.io + Redis Pub/Sub (example with tests!!)
License: GNU General Public License v2.0
:speech_balloon: Real-time Chat using Hapi.js + Socket.io + Redis Pub/Sub (example with tests!!)
License: GNU General Public License v2.0
Nodemon is not in the devdependencies so the npm start
script throws an error.
Given that the Lab Coverage Reporter is Telling me Tall Tales of incomplete coverage, we might be forced to use Lab instead ...
see: #5
Given that QUnit refuses to run all the tests in the /test directory ... see: http://stackoverflow.com/questions/31312650/how-to-run-several-qunit-node-js-test-files-using-a-single-command
We may be forced to migrate to using Lab ...
(Which isn't all that bad as its more Hapi.js focussed testing framework, which means this will be a more shareable tutorial ...)
Add riot.js with server-side initial page render and progressive enhance on client side?
What's the best solution: add to the README or add a default?
What do people think about the idea of de-coupling the UI from the API so we can independently test different UI ?
While linting #73
We see that there are a couple of errors that are being allowed to go "un-handled"
(i.e. bugs in the app!) ๐
This can easily be handled using https://github.com/dwyl/hapi-error
Myself and Maths Gregory (aka @mantagen) will be attempting to add functionality to display a preview of an image link in a small box situated in the chat feed.
https://hapi-chat.herokuapp.com/
sad panda ... ๐ผ ๐ข
Should we load previous messages when the page loads? and if so, how many?
Hi, guys, I am wondering what would be the best practice to add rooms to this chat. And how to handle the room from the client to the handler?
Thank you.
flexbox
isn't supported in any version of IE under 11, so why have we chosen to use it?
We need to add a line to the documentation on this decision and the priorities for this repo, as per the comments above.
When the repo is downloaded, and you run npm run test
, the 3rd test in server.js hangs.
We found it could be resolved by JSON.stringify
ing the res.payload
At present we have:
socket.on('message', function (msg) {
redisClient.HGET("people", socket.client.conn.id, function (err, name) {
if (err) {
console.log(err);
}
var obj = { // store each message as a JSON object
m: msg,
t: new Date().getTime(),
n: name
}
var str = JSON.stringify(obj)
redisClient.RPUSH("chat", str);
io.emit('message', str);
})
});
We should de-couple the io.emit('message, str)
from the socket.on('message' ...
e.g: https://travis-ci.org/dwyl/hapi-socketio-redis-chat-example/builds/89520469#L510 "Unnamed assert" ... is not very intuitive to beginners.
The GIF: https://camo.githubusercontent.com/1265afc65b6ef7e699d5f6ebf6b4cdd9740e3789/68747470733a2f2f63646e2e7261776769742e636f6d2f6e656c736f6e69632f6e656c736f6e69632e6769746875622e696f2f6d61737465722f696d672f686170692d636861742d66756c6c2d7265732e676966
"crashes" browsers.
This was reported by @rjmk & @anniva
So we are swapping it out for a screenshot:
If you have got http://127.0.0.1:8000/socket.io/?EIO=3&transport=polling&t=
You have to write
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({
host: '0.0.0.0',
port: Number(process.env.PORT)
});
var io = require('socket.io')(server.listener);
server.start();
Should we promote this tutorial on http://hapijs.com/resources#Tutorials
by submitting a PR to: https://github.com/hapijs/hapijs.com ? ๐
this could help
function sanitise(txt) {
if(txt.indexOf("<") > -1 || txt.indexOf(">") > -1) {
txt = txt.replace(/</g, "<").replace(/>/g, ">");
}
return txt;
}
When the window is resized, the body
must continue to be the same height as the window.
If it is not, the content (messages) will be allowed to increase in height when the window is made thinner, which will cause the messages to hide behind the messages input form
as per #8.
Last comment, "And this is the last message" can no longer be seen when window is made smaller:
Is there a more efficient way of storing our data in Redis to ensure it will scale better?
@jrans mentioned this in the standup this morning?
Are you guys wondering to implement it on this project?
Does anyone implemented a HapiJS Chat with Socket.io and Redis?
We've used this in a few projects now, might as well publish?
unfortunately pushed an env file, but realised that the gitignore did not contain any means to ignore it.
can we please add it to the master. Thanks.
tidy up the code to use goodparts
Shall I submit a pull request with 1?
The window should be scrolled down to the very bottom of the messages when it loads so that the latest messages are always visible and people can scroll up if they want to see past conversations.
Currently the very top of the message history is displayed when the app loads - i.e. The first message entered into the chat, in this case "First message ever written to my local chat"
You have to manually scroll all the way down to get to the last message when this should happen automatically on load:
What do you think?
Hello,
I believe you have used Redis Cloud add-on in Heroku.
I can get 30mb storage free on Heroku but need to put in my bank card details, have you heard of any issues with this before?
Is Redis Cloud add-on in Heroku still the best approach for hosting an app with Redis? My project is very similar to your chat app.
When window.prompt allows user to input a name, it allows for null to be set (which displays as null) - I imagine this could be a problem for lots of concurrent users
See:
https://github.com/dwyl/hapi-socketio-redis-chat-example/blob/master/client.js#L8
Luckily we've solved this (written this test) before: https://github.com/ideaq/faster/blob/master/test/e2e.js#L10-L11
In our effort to help track who says what, lets prompt people for their name before they can post a message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.