0.2.1 • Published 10 years ago

meatspace-parallax v0.2.1

Weekly downloads
2
License
BSD
Repository
github
Last release
10 years ago

meatspace-parallax

Chat using LevelDB. Currently under development.

Chat Structure

user
  |
  friends
        |
        friendA   ,   friendB
              |             |
              chats         chats

Installation

> npm install

Usage

var parallax = new Parallax('you@email.com');

Add a friend

parallax.getOrAddFriend('friend@email.com', function (err, u) {
  if (!err) {
    console.log(u);
  }
});

Remove a friend

parallax.removeFriend('friend@email.com', function (err, u) {
  if (!err) {
    console.log(u);
  }
});

Get all friends

parallax.getFriends(function (err, f) {
  if (!err) {
    console.log(f);
  }
});

Verify friend exists

parallax.hasFriend('friend@email.com', function (err, u) {
  if (!err) {
    console.log(u);
  }
});

Add a chat message

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.

Remove a chat message from a friend

parallax.removeChat('friend@email.com', chatKey, function (err, c) {
  if (!err) {
    console.log(c);
  }
});

Get chat

parallax.getChat(<key>, 'friend@email.com', function (err, c) {
  if (!err) {
    console.log(c);
  }
});

Get all chats

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.

Block a user

parallax.blockUser('user@email.com', function (err, c) {
  if (!err) {
    console.log(c);
  }
});

Unblock a user

parallax.unblockUser('user@email.com', function (err, c) {
  if (!err) {
    console.log(c);
  }
});

Get a list of blocked users

parallax.getBlockedUsers(function (err, c) {
  if (!err) {
    console.log(c);
  }
});

Tests

> make test
0.2.1

10 years ago

0.2.0

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

11 years ago

0.0.9

11 years ago

0.0.7

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago