Chat using LevelDB. Currently under development.
user
|
friends
|
friendA , friendB
| |
chats chats
> npm install
var parallax = new Parallax('you@email.com');
parallax.getOrAddFriend('friend@email.com', function (err, u) {
if (!err) {
console.log(u);
}
});
parallax.removeFriend('friend@email.com', function (err, u) {
if (!err) {
console.log(u);
}
});
parallax.getFriends(function (err, f) {
if (!err) {
console.log(f);
}
});
parallax.hasFriend('friend@email.com', 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('friend@email.com', chatKey, function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getChat(<key>, 'friend@email.com', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getChats('you@email.com', <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('user@email.com', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.unblockUser('user@email.com', function (err, c) {
if (!err) {
console.log(c);
}
});
parallax.getBlockedUsers(function (err, c) {
if (!err) {
console.log(c);
}
});
> make test