Chat using LevelDB. Currently under development.
user
|
friends
|
friendA , friendB
| |
chats chats
> npm install
var parallax = new Parallax('[email protected]');
parallax.getOrAddFriend('[email protected]', function (err, u) {
if (!err) {
console.log(u);
}
});
parallax.removeFriend('[email protected]', function (err, u) {
if (!err) {
console.log(u);
}
});
parallax.getFriends(function (err, f) {
if (!err) {
console.log(f);
}
});
parallax.hasFriend('[email protected]', function (err, u) {
if (!err) {
console.log(u);
}
});
var chat = {
media: 'http://someimage.jpg',
recipients: ['user1', 'user2']
};
chat.recipients.forEach(function (user) {
parallax.addChat(user, 'hola!', chat, function (err, c) {
if (!err) {
console.log(c);
}
});
});
If you want to also store a some url or base64 string, pass it under media - otherwise, you can leave this out.
Recipients are optional, but if you want to keep superficial track of who you sent the message to, add it here. You will still have to broadcast the message across manually.
parallax.removeChat('[email protected]', chatKey, function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getChat(<key>, '[email protected]', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getChats('[email protected]', <key>, <reverse>, function (err, c) {
if (!err) {
console.log(c);
}
});
key
is an optional point in which you want to start a chat stream from - set to false if you want it to default to the beginning.
reverse
is an optional boolean to reverse the chat history from latest -> earliest. Defaults at earliest -> latest.
parallax.blockUser('[email protected]', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.unblockUser('[email protected]', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getBlockedUsers(function (err, c) {
if (!err) {
console.log(c);
}
});
> make test