Giter Site home page Giter Site logo

advanced-chat's Introduction

Chat app written in node.js and socket.io

Libraries used

  • node.js / npm
  • socket.io
  • express
  • node-uuid
  • underscore
  • ejs

Functionality

  • People are able to join the chat server after entering their names
  • Usernames are unique - if a username is taken, a new suggestion is generated
  • User agent and geo location are both detected
  • People can setup a room. Room names are unique. One person can create on room and join one room
  • Users have to join a room to chat, except for the whisper feature.
  • Whisper messages are private messages sent between two users
  • With a WebSpeech enabled browsers, users can record their messages
  • Users can leave a room and/or disconnect from the server anytime
  • New: People joining the room will see the past 10 messages (chat history).
  • New: People will see an 'is typing' message when someone is typing a message.

Setup and configuration

Make sure that you update server.js:

server.listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

and add your own IP address/hostname if required, i.e.:

server.listen(app.get('port'), "192.168.56.102", function(){
  console.log('Express server listening on port ' + app.get('port'));
});

(the port is defined in the app.set('port', process.env.PORT || 3000); section.)

Please also update public/js/client.js:

var socket = io.connect("192.168.56.102:3000");

with the right IP address/hostname.

To install npm install && bower install and to launch run npm start.

Whisper

To send a 'private' message, use the following format in the chat message input box: w:USERNAME:MESSAGE (where 'USERNAME' is the exact name of the user who you wish to whisper to (case-sensitive). For your convenience you can use the whipser link next to the person's username on the left hand side.)

New up to date post: http://tamas.io/further-additions-to-the-node-jssocket-io-chat-app/

Previous articles related to this topic:

Learn the latest on web development

https://fullstack-developer.academy

advanced-chat's People

Contributors

austinkelleher avatar dspinellis avatar guysch avatar jfrattarola avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

advanced-chat's Issues

404 error for static files.

Hey there,

I'm attempting to run this on OpenShift, and I get to the HTML but I get the following 404's (see below).
I assume it's a problem with Express but I cannot for the life of me figure out what.

Failed to load resource: the server responded with a status of 404 (Not Found)
http://nodesocketapp-dodan.rhcloud.com/components/font-awesome/css/font-awesome.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://nodesocketapp-dodan.rhcloud.com/components/bootstrap/dist/js/bootstrap.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://nodesocketapp-dodan.rhcloud.com/components/jquery/dist/jquery.js Failed to load resource: the server responded with a status of 404 (Not Found)
client.js:82 Uncaught ReferenceError: $ is not defined
http://nodesocketapp-dodan.rhcloud.com/components/bootstrap/dist/css/bootstrap.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://nodesocketapp-dodan.rhcloud.com/components/font-awesome/css/font-awesome.css Failed to load resource: the server responded with a status of 404 (Not Found)

Chat does not work

Hello, I am new in this area, and I'm trying to try this script, but it does me is working is so, is it could help me?

bepqqxp

screenshot_4

Demo Online!

Dude!
Can u deploy demo online because I cant build your project!

client directory for jquery.js

I installed the current version on Ubuntu 12.04. The directory for jquery.js was incorrect. It needs to have ./dist added so that the entire directory is:

components/jquery/dist/jquery.js

problem with whispering to user

hi.. i got a problem with whispering to other user..

problem is here
okay, when client A send "hello" whisper to client B,
client A got this message "NaN:NaN:NaN undefined whispers: undefined"
while client B got this message "20:43:03 pja whispers: hello"

how to fix this thing?

screenshot
client A
screenshot_29

client B
screenshot_30

CPU Increasing 104%

Hello Tamas,

I was newbie for using socket.io and your advanced-chat project was really great for me to learn about chat engine with socket.io.
But When I try to use it, the cpu always heap until 104%, so the next request can't handle by server. So it always show warning "WebSocket is closed before the connection is established". What should I do Tamas? Is there any way to fix this issue?
My server spec is 4 CPUs and 8GB RAM.

Cheers.

whisper error

hi

in whisper message

io.sockets.socket(whisperId).emit("whisper", people[socket.id], whisperMsg)

this is not working anymore in socket.io 1.x

is there any solution for this?

thanks.

setup error

when i try to setup localy i get this error

[email protected] install C:\Users\Mohamed\Desktop\ya rab\node_modules\socket.io\node_
modules\socket.io-client\node_modules\ws
(node-gyp rebuild 2> builderror.log) || (exit 0)

C:\Users\Mohamed\Desktop\ya rab\node_modules\socket.io\node_modules\socket.io-cl
ient\node_modules\ws>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp
-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild
/

[email protected] postinstall C:\Users\Mohamed\Desktop\ya rab
./node_modules/bower/bin/bower install

'.' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! [email protected] postinstall: ./node_modules/bower/bin/bower install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the chat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./node_modules/bower/bin/bower install
npm ERR! You can get their info via:
npm ERR! npm owner ls chat
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! cwd C:\Users\Mohamed\Desktop\ya rab
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\Mohamed\Desktop\ya rab\npm-debug.log
npm ERR! not ok code 0

any help please ?

Error when I start the server

I got the following error message:

Error: EACCES, permission denied '/var/run/advanced-chat.pid

What could be wrong? Thanks.

app.configure<function> error

when starting node server.js i get an error:

app.configure<function()

typeError: undefined is not a function...

could you please help me fix this?
thanks

proxy

i have this chat running from a nginx proxy, and when i load it from the url everything works, but when i embed the script into my site and connect it doesnt work.
Any idea ?

Css problem

css problem and nothing is displayed when we type any message or create room

Spaces in people-names breaks "is-typing" functionality.

Just FYI, the selector breaks when a person has a name like "Some Bro", anything with a space. I didn't clone your repo or anything so I'm just posting the issue + fix here. In clien.js

socket.on("isTyping", function(data) {
if (data.isTyping) {
if ($("#"+data.person.split(' ').join('-')+"").length === 0) {
$("#updates").append("<li id='"+ data.person.split(' ').join('-') +"'> " + data.person + " is typing.");
......MY CUSTOM CALLBACK, OMITTED
}
} else {
$("#"+data.person.split(' ').join('-')+"").remove();
}
});

As you can see it's a simple matter of splitting where any spaces are and joining by a non space char. Cool app, much thanks for sharing it. :)

Coming back to a room

The server crashed when I tried the following:
one person creates a room, another person joins it, then leaves it and tries to come back. The system info says: You are already in a room (Dev's room), please leave it first to join another room.

and the log from the server:

info - socket.io started connect.multipart() will be removed in connect 3.0 visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives connect.limit() will be removed in connect 3.0 Express server up and running. match: false undefined match: false matched person T1's room match: false /Users/and_re/Sites/advanced-chat/server.js:229 date", "You are already in a room ("+rooms[people[socket.id].inroom].name+"), ^ TypeError: Cannot read property 'name' of undefined at io.sockets.on.socket.on.room (/Users/and_re/Sites/advanced-chat/server.js:229:94) at check (/Users/and_re/Sites/advanced-chat/server.js:37:20) at process.startup.processNextTick.process._tickCallback (node.js:244:9) 29 Oct 10:33:23 - [nodemon] app crashed - waiting for file changes before starting...

Updating to socket 1.0 and Express 4

Took a liberty of copying your code and make it run under socket.io ver 1 and express 4 located here: https://github.com/forddyce/programme-chameleon/tree/master/public/app

Was going to add download feature (I will add a table and when a user clicks on download button the

will export as xlsx and download, table created by room master and downloadable by participants). Also going to add feature on showing what room I'm currently at, and a "logout" button without the need of refreshing the page. Any ideas on the feature I mentioned?

Um I get an issue with chat @0.01

this is the debug log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files (x86)\nodejs\node.exe',
1 verbose cli 'C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink C:\Program Files (x86)\nodejs\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart [email protected]
7 info start [email protected]
8 verbose unsafe-perm in lifecycle true
9 info [email protected] Failed to exec start script
10 error [email protected] start: node server.js
10 error Exit status 1
11 error Failed at the [email protected] start script.
11 error This is most likely a problem with the chat package,
11 error not with npm itself.
11 error Tell the author that this fails on your system:
11 error node server.js
11 error You can get their info via:
11 error npm owner ls chat
11 error There is likely additional logging output above.
12 error System Windows_NT 6.1.7601
13 error command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "start"
14 error cwd C:\Users\Sharon\Desktop\advanced-chat-master
15 error node -v v0.10.35
16 error npm -v 1.4.28
17 error code ELIFECYCLE
18 verbose exit [ 1, true ]

how to integrate with angularjs ??

Advanced-chat is not working well with my angularjs project..
I want to integrate this with my project.. may be i have some problem with jquery?

I have some questions for the following codes.

From my experience on underscore.js, I don't really understand the following codes.
Do you think that it's the right way on using the call of contains(".contains") ?
For example, in the logic " if(
.contains((room.people)), s.id) ", (_.contains((room.people)), s.id) is always true, because s.id is always greater than 0.

If so, kindly review the following codes, and let me know.

https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L80
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L75
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L100
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L105
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L121
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L126
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L141
https://github.com/tamaspiros/advanced-chat/blob/master/server.js#L154

whisper

When whispering to self two error messages are displayed ('can't find ' and 'can't whisper to self') - former is not correct as user == self therefore user exists.

Multiroom per user feature

Hi ;) nice and well-explained source code.
Can a user belongs to more than one chat-room?? E.g., participate in two or more chat rooms.
How can I achieve this?

Thanks ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.