npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-elastos-carrier

v0.1.0

Published

react native plugin for elastos carrier

Downloads

317

Readme

React Native Elastos Carrier Plugin

The purpose of this repository is to provide an npm package for Elastos React Native Framework Alpha Release.

Elastos Carrier is a decentralized peer-to-peer platform that takes over all network traffic between virtual machines and conveys information on applications’ behalf.

The release version for plugin is here

Primary Code Reviewer

Jacky Li

Getting started

npm install --save react-native-elastos-carrier

react-native link react-native-elastos-carrier

Next step

iOS

  • open xcode
  • add ElastosCarrier.framework to Linked Frameworks and Libraries from /node_modules/react-native-elastos-carrier/ios/Carrier folder
  • run project

Android

add following lines to project build.gradle

flatDir{
    dirs "$rootDir/../node_modules/react-native-elastos-carrier/android/libs"
}

under allprojects repositories block.

Usage

const carrier = new Carrier('app_name', {
    // carrier callback
});
await carrier.start();

API List

static getVersion

  • return current Carrier version
Carrier.getVersion();

static isValidAddress(address)

  • check address is valid for carrier node or not.
  • return boolean.
Carrier.isValidAddress('Xm4WXfsSbAHhwiAe6tdo3oxhH93p8jb6Kata9ywyohkjssBMAH8n') // true
Carrier.isValidAddress('abcde') //false

getAddress

  • return current instance address
const address = await carrier.getAddress();

getSelfInfo

  • return current node profile info.
const selfInfo = await carrier.getSelfInfo();
/*
 userId: 'EzhQQz9X3nR6NYb2makCpmZjnuiFsD11CGuak9FnE8hf',
 gender: 'male',
 region: 'China',
 phone: '123456789',
 email: '[email protected]',
 description: 'I am a node for Elastos carrier',
 name: 'new world',
 */

setSelfInfo(info)

  • set self profile info for current node.
await carrier.setSelfInfo({
    gender: 'male',
    region: 'China',
    phone: '123456789',
    email: '[email protected]',
    description: 'I am a node for Elastos carrier',
    name: 'new world',
});

setSelfPresence(presence)

  • set self presence status
// presence status
{
    'ONLINE' : 0,
    'AWAY' : 1,
    'BUSY' : 2
}

await carrier.setSelfPresence(Carrier.config.PRESENCE_STATUS.AWAY);

addFriend(address, msg)

  • pair with new carrier node as friend.
  • return boolean.
await carrier.addFriend('Dg3h2TecXGzBU5NruvdYaMJoCdxGc3etPmJ6GVynKpLUm1whnQyE', 'hello');

acceptFriend(userId)

  • accpet pair request from another carrier node.
  • userId is friend node userId, not address.
  • return boolean
this.carrier.acceptFriend('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV');

getFriendInfo(userId)

  • return friend node info
const friendInfo = await carrier.getFriendInfo('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV');

/*
 gender: 'male',
 region: 'China',
 phone: '123456789',
 email: '[email protected]',
 description: 'I am a node for Elastos carrier',
 name: 'new world',
 label: 'friend',
 status: 0,
 presence: 0
 */

removeFriend(userId)

  • remove friend.
await carrier.removeFriend('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV');

getFriendList

  • return current node friends list
  • return data structure is friend info.
const friendList = await carrier.getFriendList();

setLabel(friendId, label)

  • set friend label
await carrier.setLabel('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV', 'label')

sendMessage(friendId, message)

  • send a message to friend.
  • return boolean
await carrier.sendMessage('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV', 'hello world');

close

  • close carrier node

clean

  • remove carrier node file from device. that means the node will be gone.

createSession(friendId, streamType, streamMode)

await this.carrier.createSession(
    '4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV',
    Carrier.config.STREAM_TYPE.TEXT,
    Carrier.config.STREAM_MODE.RELIABLE
);

sessionRequest(friendId)

  • send session request to friendId
await this.carrier.sessionRequest('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV')

sessionReplyRequest(friendId, status, reason)

  • accept or refuse session request
  • status=0 accept, status=1 refuse.
  • if refuse. reason is avaiable.
await this.carrier.sessionReplyRequest('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV', 0, null);

writeStream(streamIdOrFriendId, data)

  • write data to stream
  • streamId or friendId both available.
await this.carrier.writeStream('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV', 'stream data ...');

removeStream(friendId)

  • remove stream from session
await this.carrier.removeStream('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV');

closeSession(friendId)

  • close session
await this.carrier.closeSession('4ni3UKYY9xHDcodNaP1edAWDGuF5cmWTU8QWH4JnNfwV');

Plugin configuration

    CONNECTION_STATUS : {
      'CONNECTED' : 0,
      'DISCONNECTED' : 1
    },
    PRESENCE_STATUS : {
      'ONLINE' : 0,
      'AWAY' : 1,
      'BUSY' : 2
    },
    STREAM_TYPE : {
      'AUDIO' : 0,
      'VIDEO' : 1,
      'TEXT' : 2,
      'APPLICATION' : 3,
      'MESSAGE' : 4
    },
    STREAM_STATE : {

      Initialized: 1,
      TransportReady: 2,
      Connecting: 3,
      Connected: 4,
      Deactivated: 5,
      Closed: 6,
      Error: 7
    },
    STREAM_MODE : {
      COMPRESS: 1,
      PLAIN: 2,
      RELIABLE: 4,
      MULTIPLEXING: 8,
      PORT_FORWARDING: 16
    }