Giter Site home page Giter Site logo

ajaxim's Introduction

Ajax IM

What is Ajax IM?

Ajax IM ("Ajax Instant Messenger") is an instant messenger for the web. It is intended to be integrated with existing websites to provide a more interactive community experience.

Features

  • Instant communication between connected users
  • Robust backend server built on Node.js
  • Can be integrated with virtually any existing website
  • Seamless authentication
  • Works across an entire website, unobtrusively
  • Automatic state management between page reloads
  • User state and statuses
  • and much more!

Installation

Install Node.js:

wget http://nodejs.org/dist/v0.8.9/node-v0.8.9-linux-x86.tar.gz
tar xzf node-v0.8.9-linux-x86.tar.gz
cd node-v0.8.9
./configure
make
make install

Install Node Package Manager (npm):

See instructions at http://github.com/isaacs/npm.

Install Express.js, Connect and Cookie:

npm install express
npm install connect
npm install cookie

Compile the daemon add-on if you plan on letting the server daemonize itself:

cd server/libs/daemon
node-waf configure build
cp build/default/daemon.node .
rm -rf build

Installation for Development

If you want to test Ajax IM as a standalone app for development, you will need to install Jade as well.

To install Jade:

npm install jade

Starting up the server

Starting the server in development mode is as simple as:

node server/app.js

To start the server in production mode:

EXPRESS_ENV=production node server/app.js

To start the server as a daemon in production mode:

node server/app.js start production

Testing it out

Once the server is up and running in development mode, you can test it out through the included development testing app. The below instructions are assuming that you have left all default configuration options. If not, please replace the host/port values with the correct ones.

To get started, first initialize a session cookie by going to:

http://localhost:8000/dev/cookie

Then head over to the development page that will initialize the client:

http://localhost:8000/dev/

That's it!

More Information

Node Compatibility

The master branch of Ajax IM is compatible with node --version:

v0.8.9

Contributing

Pull requests are being accepted! If you would like to contribute, simply fork the project and make your changes.

Style Guide

If you intend on contributing, please follow this style guide when submitting patches or commits. Submissions that do not follow these guidelines will not be accepted.

  • Use 4 space indents (not tabs!)
  • No trailing whitespace
  • Blank line at the end of files
  • Semi-colons at the ends of lines, where appropriate
  • Keep lines to 80 characters or less
  • Never bump the version

No whitespace between keys and values:

{foo: 'bar'}
// good

{foo : 'bar'}
// bad

Hash formatting:

{foo: 'bar', baz: 'taz'}
// good

{
    foo: 'bar',
    baz: 'taz',
    moo: 'cow'
}
// good

{ foo: 'bar', baz: 'taz' }
// bad

{foo: 'bar',
 baz: 'taz',
 moo: 'cow'}
// bad

Chained methods:

str
    .strip
    .replace(...)
    .replace(...)
// good

str
.strip
.replace(...)
.replace(...)
// bad

str.
    strip.
    replace(...).
    replace(...)
// bad

Single quotes over double quotes, unless double quotes make sense:

'hello'
// good

"what's up?"
// good

"hello"
// bad

Ternary expressions are fine, but cannot be nested and must be formatted as:

foo = (a ? b : c);
// good

foo = (something.hasAPropertyLikeThis == 'some other value'
           ? 'result one'
           : 'result two'
      );
// good

foo = something.hasAPropertyLikeThis === 'some other value' ?
          'result one' :
          'result two'
// bad

Use braces for conditionals, unless conditionals are single statements:

if(foo) {
    bar();
    baz();
}
// good

if(foo) bar();
else baz();
// good

if(foo)
    bar(),
    baz()
// bad

Closures:

function() {
}
// good

function () {
}
// bad

function()
{
}
// bad

Methods:

foo.bar = function() {
}
// good

foo.bar = function (){
}
// bad

foo.bar = function()
{
}
// bad

License

(The MIT License)

Copyright (c) 2012 [Daniel Howard] (http://www.svexpertise.com)
Copyright (c) 2010 Joshua Gross

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ajaxim's People

Contributors

ajaximrpg avatar endtwist avatar loe avatar mburtscher avatar proppy 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

ajaxim's Issues

Users are identified by their username

Because users are identified just by their name, you can't use the library for a bigger website with users having the same names. E.g. facebook does not use "usernames" but "real names" instead which may occur more than once in a contact list.

Installation instruction should list ext.js dependency

Hi,

After installation and trying to run the server according to the README instructions, I had the following error:
aminche:~/AjaxIM# node server/app.js

node.js:275
    throw new Error("Cannot find module '" + request + "'");
      ^
Error: Cannot find module 'ext'
at loadModule (node.js:275:15)
at require (node.js:411:14)
at Object.<anonymous> (/root/AjaxIM/server/app.js:6:22)
at Module._compile (node.js:461:23)
at Module._loadScriptSync (node.js:468:10)
at Module.loadSync (node.js:338:12)
at Object.runMain (node.js:521:24)
at node.js:751:10

Does anyone have it running properly?

Hey guys,

I've been trying to make it work for like 3 days now and I can't think of anything to fix it... And when I fix something, I get a new error...

Newest error:

Error: {"type":"error","error":"not authenticated"}
at Object.session as handle
at next (/root/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Object.bodyParser as handle
at next (/root/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Object.cookieParser as handle
at next (/root/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Object.methodOverride as handle
at next (/root/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Object.handle (/root/node_modules/express/lib/http.js:85:5)
at next (/root/node_modules/express/node_modules/connect/lib/http.js:204:15)

But on http://localhost:8000/dev/Cookie I get the "Cookie set" message, what is this happening?

On http://localhost:8000/dev, I just get the "hello" message and nothing else, no bar, no nothing... that's pretty exhausting too plus I don't even know if it'll work at the end..

H.E.L.P, please...

Thank you

How to add a new friend in the DB

Hi,
I want to add a new user in the friend list of someone with a MySQL query, but i don't understand how the friend management system works, and the menu "Database Backends" is not available on the official website.

Help would be greatly appreciated ;) Thanks.

Friends list does not get updated for previously logged in users.

What happens is this:

Lets say UserA logs into the site and has 0 friends logged in.

UserB logs in and is friends with UserA. UserB will have UserA in its
friends list, but UserA's own friends list will not be refreshed.

The only way to refresh UserA's own list is to log in and log out
again, but this defeats the purpose.

Also, in the same example lets say UserA and UserB both see each
other. When UserB logs off, UserA gets no notification and can still
chat to UserB.

Missing table prefixes

In MySQL.php of the DB libraries, you have some hardcoded table prefixes. They are in the getMany function of the MySQL_Message class.

This is the hardcoded SQL statement:
$get_sql = "SELECT message_id, u1.username as from, u2.username as to, message, type, sent FROM " . MYSQL_PREFIX . "messages as m
LEFT JOIN ajaxim_users as u1 ON m.to_id = u1.user_id
LEFT JOIN ajaxim_users as u2 ON m.from_id = u2.user_id WHERE ";

This is what it should look like:
$get_sql = "SELECT message_id, u1.username as from, u2.username as to, message, type, sent FROM " . MYSQL_PREFIX . "messages as m
LEFT JOIN " . MYSQL_PREFIX . "users as u1 ON m.to_id = u1.user_id
LEFT JOIN " . MYSQL_PREFIX . "users as u2 ON m.from_id = u2.user_id WHERE ";

Replace Memcache server API with REST API

Create a REST API for the Ajax IM server using "secret key"-based authentication. API should be able to authenticate a user session, and manage user sessions (delete, modify, etc).

API options:

  • user_status
  • set_status
  • destroy_session
  • send_message
  • broadcast

disconnect after a minute (guest), and a few interesting things :)

1.) i'm testing the guest mode (latest) on my server and it seems to work but in a conversation, the client who sends the last message, will be disconnected after a minute.
if no messages are sent, the server keeps the client logged in.
as i see the same happens on ajaxim.com.
2.) i opened ajaxim.com in firefox, it reports 12 friends, the same time in safari this number is 4 only.
3.) the client itself is listed on the friends list - not nice :)
4.) if the sent message text is a number, the received message is "{message}". in this case, the recipient will be logged out, not the sender :))))
5.) feature req: i'd like to see a "pick a username" field in guest mode :)

AjaxIM.init is not a function

This is what it shows firebug when i load a page that contains the "registration form"

<div id="ajaxim">
 <script type="text/javascript">
    AjaxIM.loaded(function() { AjaxIM.client.form('#ajaxim'); }); // Line 233 !!!
 </script>
</div>

AjaxIM.init is not a function
im.load.js?php
Line 50

AjaxIM.init is not a function
init()im.load.js?php (line 50)
loadDep()im.load.js?php (line 29)
nextdep()im.load.js?php (line 37)
[Break on this error] flashStorage: jsfolder + 'jStore.Flash.html'

Hide users with offline status

Users with the status "offline" should not be visible on the friends list, nor counted toward the "Friends (X)" count in the tab.

Add Room reaper

Inactive Rooms should be reaped (removed) periodically to free up memory.

  • Private rooms should be reaped regardless of whether or not there are still active participants, as long as nothing has been said for a period of time.
  • Public rooms should not be reaped if there are still active users in the room. Scrollback logs, however, can be shortened periodically, regardless of participation.

Selecting text doesn't always work

In FF3.6 / XP SP3, selecting text often will be deselected and the focus will move to the input box.

I originally thought moving from one direction worked more often than the other, but realized that wasn't the case.

Thank you for AjaxIM!

Adding user (initiator and accepter) on the fly and updating friend list

Scenario:

User A sends a friend request to User B.
User B then accepts the friend request, on acceptance:
User B gets User A added only if User A is online.
If User A is online then their friend list gets User B added.

You can add users via the script using:

  • //AJAXIM: Add this user to friends list
    im.addFriend(friendname, "Available", 'Friends');
  • Send notification to other friend to add this user
    im.send(friendname, "_newfriend"); //AJAXIM

In im.js around line 473: incoming: function(from, message...

add:

//Add to AJAXIM friends list
if (message == "_newfriend") {
im.addFriend(from, "Available", 'Friends');
return false;
}

But this seems hackish and is limited to the clientside.

I propose this mechanism:

  1. User A sends a friend request.
  2. User B accepts friend request.
  3. From User B: New status update is sent to the server adding User A to (User B) session.
  4. For User B: On clientside, if User A online then add to (User B) friend list.
  5. For User A: If Online, new status update is sent to User A notifying of new friend to be added (User B) and (User A) session updated.

Comments welcome.

Add permissions handling

Permissions handling would be useful to allow for administrators and moderators in the chat. It would also provide flexibility with allowing or disallowing various features. Permissions should probably be integrated with the authentication set of libraries and functions.

A requirement for a public has_permission(user, perm) function in the particular libs/authentication/*.js library would probably be an acceptable solution for flexibility.

Problems with ÄÜÖ in username

Hi,

I had a bit of trouble with json strings not beeing recieved correctly. It turns out that you set the Content-Length header with message.length, which just counts the characters in the stringified JSON code.
However this is incorrect, you will need to count the bytes in that string.

This does the job for me:
var length = require('buffer').Buffer.byteLength(message);

The problem occured in user.js

Thanks for AjaxIM

Message storage should be HTML

In order to speed up the process of storing and retrieving messages, messages should be stored as HTML (one message per array item).

UI should keep tabs & active tab in same place b/w pages

When the user reloads/changes pages, the UI should try to restore the tabs to both the same order and place the active tab in the same location it was on the prior page.

Ideally, this could be done by checking the list of tabs and finding the position of the active one, as well as whether or not it is visible (and if so, at what position/index it is in the visible tabs).

Remove reliance on ext.js library

The ext.js library is, by and large, unnecessary and merely a convenience. It can be removed and replaced with a simple utils library.

Is ajaxim actually ok to be use?

The site hasn't been updated in a long time. I have a site in node.js and mongodb that I'm looking to integrate with ajaxim.

Need some documentation though, something along the lines of:

  1. call this function when adding users sessions
  2. put the rest url for friendlists here.

Thanks!

Session culling issue

User closes browser but session open with nodejs. The session never gets culled with inactivity over 5 minutes.

"Can't set headers after they are sent" in Express next() function.

In the authentication library index.js (export.friends):

response.on('end', function() {
try {
callback(JSON.parse(data));
} catch(e) {
console.log("ERROR: "+e.message);
callback();
}
});

Whenever a user logs in the "try" callback is running and successfully logging them in, but then an error is thrown in the Express next() function located near the end of im.js:

...
res.signOff = function() { store.signOff(req.sessionID); };

next();
...

The e.message prints out "Can't set headers after they are sent".

Also, when callback() is run in the catch section with no arguments there is a fatal error because "friends" is undefined and trying to be sliced in hub.js "var friends_copy = friends.slice();".

When I comment out callback() in the catch section I get signed in with no problems. An object is returned with my username and the list of friends expected from my getuser.php and getfriends.php. I am even able to sign in other users and chat successfully, but I am getting lots of other problems if users sign in and out. I figure these other random problems could be related to the error when the user logs in.

I've been trying to get this setup for a week now and feel very close.

Thanks for your help.

Add prefs button to set user status

There should be a button to the right of the friends list that lets a user set their status and any other preferences that might be necessary. The button's icon should also serve a status indicator.

ENOTDIR ajaxim error

hey i dont know whats wrong
i already follow all the instruction
and everything seems to run fine
i able to set the cookies on /dev/cookie
but when on /dev/
i got this ENOTDIR error

127.0.0.1 - - [Wed, 10 Nov 2010 04:21:59 GMT] "GET /js/jquery.jsonp-1.1.3.min.js
HTTP/1.1" 500 - "http://localhost:8000/dev/" "Mozilla/5.0 (Windows; U; Windows
NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/53
4.7"
Error: ENOTDIR, Not a directory '/home/mufi/endtwist-AjaxIM-3d667cf/server/dev/p
ublic/js/im.js'

any clues on what happen?
it seems it cannot load all the file needed >.<

Remove "Comet" and Short Polling methods

Remove "Comet" (uses a very ugly streaming method) and Short Polling as options in im.js. Also remove the pollType configuration option, as Long Polling will become default (until Web Sockets gains wider acceptance).

IE 7 & 8 Access Denied jquery.jsonp-1.1.0.js

AjaxIIM initally works in IE but after loading once the access denied error prevents it from functioning.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Mon, 12 Apr 2010 15:59:32 UTC

Message: '$.jStore.Availability' is null or not an object
Line: 180
Char: 25
Code: 0
URI: http://ajaxim.com/wp-content/plugins/im/js/im.js

Message: '$.jStore.Availability' is null or not an object
Line: 180
Char: 25
Code: 0
URI: http://ajaxim.com/wp-content/plugins/im/js/im.js

Message: Access is denied.

Line: 165
Char: 4
Code: 0
URI: http://ajaxim.com/wp-content/plugins/im/js

No login function in im.js

Hi,

I'm currently trying to get ajaxim (latest from git) running with node server. There is no login (or) logout function in the current im.js.
How do i authenticate now?

Regards,

Christian

node.js version?

which version of node.js should be used?
because i see major changes in the changelog of it.

i installed 0.1.18 (as suggested on ajaxim homepage), on startup it sends this message: (evcom) bind() Cannot assign requested address.
after a successful connection (User connected blah blah) communication stops, and i cannot connect again until i delete the cookie from the browser.
i use the latest version of ajaxim downloaded from here.

issue on Ubuntu 10.04 LTS (lucid)

Hello folks,

Somebody, please help !
I'm trying to make Ajaxim work under Ubuntu 10 for the last two days without success.
I'm following the guide available at: https://github.com/endtwist/AjaxIM/wiki/Getting-Started

After dealing with openssl + node installation (libssl-dev package is required but not mentioned on that tutorial), I'm still getting error about 'cookieDecoder' method when trying to run Node.js:


root@ubuntu:/tmp/AjaxIM# node server/app.js

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object # has no method 'cookieDecoder'
at Object. (/tmp/AjaxIM/server/app.js:57:13)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array. (module.js:423:10)

at EventEmitter._tickCallback (node.js:126:26)

root@ubuntu:/tmp/AjaxIM# ls -al
total 16
drwxr-xr-x 6 root root 180 2011-04-13 11:59 .
drwxrwxrwt 17 root root 420 2011-04-13 12:39 ..
drwxr-xr-x 2 root root 60 2011-04-13 11:59 build
drwxr-xr-x 4 root root 80 2011-04-13 11:59 client
drwxr-xr-x 8 root root 260 2011-04-13 11:59 .git
-rw-r--r-- 1 root root 136 2011-04-13 11:59 .gitignore
-rw-r--r-- 1 root root 861 2011-04-13 11:59 Makefile
-rw-r--r-- 1 root root 5819 2011-04-13 11:59 README.md
drwxr-xr-x 5 root root 140 2011-04-13 11:59 server

root@ubuntu:/tmp/AjaxIM# ls -al server
total 8
drwxr-xr-x 5 root root 140 2011-04-13 11:59 .
drwxr-xr-x 6 root root 180 2011-04-13 11:59 ..
-rwxr-xr-x 1 root root 3713 2011-04-13 11:59 app.js
drwxr-xr-x 4 root root 100 2011-04-13 11:59 dev
drwxr-xr-x 4 root root 120 2011-04-13 11:59 libs
drwxr-xr-x 3 root root 80 2011-04-13 11:59 middleware
-rw-r--r-- 1 root root 814 2011-04-13 11:59 settings.js

Stop using .data for friends list info

Right now, data (state, for individual users on the friends list) is stored using jQuery's .data method. This is hackish and ugly — it would be better to have a single reference to the username, and then find the username in an AjaxIM-managed list.

Check status CHANGES on client side

I use "long" requests and my own server-side implementations for the login/poll/post handlers.

At the end of every "poll" request (after 30 seconds) I wanted to send the whole contact list to the client with current statuses of all users. So I added a "status update" message for every user in the contact list. But because AjaxIM doesn't check status CHANGES on client side, i get an output like this in the chat window:
05:28 PM - user became available.
05:28 PM - user became available.
05:29 PM - user became available.
05:29 PM - user became available.
05:30 PM - user became available.
05:30 PM - user became available.

I think status CHANGE checks should be implemented on client side. So if user x is already online and a "status update" message was sent as response to the "poll" request, the new status should only be shown if it really changed.

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.