@activatortube/supernova-sdk
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

SuperNova SDK项目

基于socket.io实现

Usage

安装

Web

npm install @activatortube/supernova-sdk
# 或者
yarn add @activatortube/supernova-sdk

React Native

  1. 添加依赖
# 1. 添加依赖
npm install @activatortube/supernova-sdk
# 或者
yarn add @activatortube/supernova-sdk
# 2. 添加react-native-get-random-values,比Web需要多一步
yarn add react-native-get-random-values
  1. 安装依赖
npx pod-install
  1. 然后在项目的起始位置引用
import 'react-native-get-random-values';

例子

import 'react-native-get-random-values';
import SuperNova from '@activatortube/supernova-sdk';

const Chat = () => {
  useEffect(() => {
    // 初始化项目
    SuperNova.init(Config.SUPERNOVA_ENDPOINT, 'debug');
    // 登录到聊天服务器
    const instance = SuperNova.getInstance();
    instance.login('', '');
    
    // 添加消息事件
    const messageHandler = (message: Message) => {
      console.log(`收到一条新消息:`, message);
      // TODO
    };
    SuperNova.getInstance().addMessageHandler(messageHandler);
    
    return () => {
      SuperNova.getInstance().removeMessageHandler(messageHandler);
    };
  }, []);
  // TODO
};

文档

API Reference

CHANGELOG

/@activatortube/supernova-sdk/

    Package Sidebar

    Install

    npm i @activatortube/supernova-sdk

    Weekly Downloads

    19

    Version

    2.1.1

    License

    ISC

    Unpacked Size

    62.1 kB

    Total Files

    26

    Last publish

    Collaborators

    • wheelerlee