- Published on
Node Chat App
- Authors
- Name
- interglobalmedia
- @letsbsocial1
chattr
Built with websockets library socket.io, Node.js, and Express, and React
What is it for?
For friends, family, and/or colleagues to connect in real time and communicate with each other. Messages were timestamped. chattrbox used to also use the geolocation API and Google Maps API Maps Url. The geolocation API allowed users to provide their location IF they want to. They can always choose to DENY access to their location. For privacy reasons, the user was asked permission to report location information when clicking on the Send Location button. chattrbox used the Google Maps API along with the geolocation API so that a user not only shared his/her latitude and longitude, but an actual Google Map with his/her exact location and directions how to get there. That was possible because of the implementation of Google Maps API dir (directions) mode as opposed to search mode, which was a bit less accurate.
However, in this current iteration of the
application
, I chose not to add theGoogle Maps API
andgeolocation API
features because of the increased awareness and global support ofindividuals' privacy
on theweb
.Messages
are also no longertimestamped
for the same reason.
Are chats private?
- It used to be that
chats
in eachchat room
that was created by auser
whenhe/she
logged in, wereprivate
within the confines of thatroom
. However, now there are no longerprivate chat rooms
, butprivate chats
betweentwo users
at atime
.
If every user can create their own private chat, how does that work?
- Each socket in
Socket.io
is identified by arandom
,unguessable
, unique identifierSocket#id
. Therefore, each socket automatically joins a"room"
identified by itsown id
. This makes it easy to createprivate messages
betweentwo users/browser window (tab) instances
. I found this to be a better use of thisSocket.io
feature than creating aroom
thatmultiple users
can join. As a result, one can createeither
apublic chat
in which themessages
are shared witheveryone
everywhere, or create aprivate chat
withone user
at a time.
How can I tell whether I am creating a private or public message?
Once you have entered your
name
in theinput field
containing theplaceholder text
"Enter name"
and hit thereturn/enter key
on yourdevice's keyboard
, yourname
appears among thelist
ofusers
who have also joinedChattr
, ifthere are
any. If there is at leastone other user
present, you canclick
on theirname
, and you will be directed to aninput field
containing theplaceholder text
"Type your message (private)"
. In addition, when youclick
on theuser
you want to have aprivate chat
with, theirname
will becomeunderlined
, indicating they are thecurrent
(selected
)user
you are chatting with privately. Aninput field
with theplaceholder text
"Type your message (public)"
also appears when you firstinput
yourname
in theinput field
with theplaceholder text
"Enter name"
, which is present when you first land on theapplication
.Photo by Maria D. Campbell on Interglobalmedia Photo by Maria D. Campbell on Interglobalmedia
How can I invite others to chat with me?
- By sharing the link to the site.
Are chats persistent?
- No. Once a
browser tab
orwindow
is closed, theuser
associated with thattab
orwindow instance
is erased along with anymessages
associated with theuser
. But you can re-use thelink
to theapplication
onHeroku
if you like and share it with others so that they can join you there.
Will the url always remain the same?
It could, but I might change it from time to time at my discretion so as to prevent abuse of the site
for potentially nefarious reasons
or for profit
. I will share the url
only with those
that I would like to share the space
with.
Project Includes
create-react-app
, eslint
, express
, heroku
, heroku cli
, homebrew
, husky
, git
, git hooks
, nodejs
, prettier
, react
, sass
, socket.io
, stylelint
, websockets
View Node Chat App live on Heroku: maria d. campbell
Socket.io Rooms: socket.io docs
Private messaging - Part I: socket.io docs