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-sf-im

v1.0.2

Published

Downloads

5

Readme

react-native-sf-im

聊天框架

安装

  • yarn add react-native-sf-im
  • yarn add react-native-sf-aliyun-oss
  • react-native link react-native-sf-aliyun-oss

Methods

| Methods | Params | Param Types | description | Example | |:-----|:-----|:-----|:-----|:-----| |init|host,port,aliyunConfig|string,string,object|聊天服务器配置以及阿里云配置|参考例子| |listen|事件监听参数|object|监听聊天所有出发事件|参考例子| |register|account,pwd,uid|string/string/string|注册用户|参考例子| |login|account,pwd,suc,fail|string/string/func/func|登录聊天系统|参考例子| |logout|||登出聊天系统|参考例子| |message|type|SFStatus.msg|创建消息结构体|参考例子| |send|message|SFIMMessage|发送消息|参考例子| |getHistory|lastMsgId,count,callBack|string/number/func|获取历史消息|参考例子| |getChatList|||获取对话列表|参考例子| |setNick|nick|string|设置昵称|参考例子| |setHeader|header|string|设置头像|参考例子|

例子


import {SFIM, SFIMMessage, SFIMConfig, SFIMStatus} from "react-native-sf-im"

# 初始化
SFIM.init({
            host:'http://127.0.0.1',
            port:'5000',
            aliyun:{
                accessKey:'',
                secretKey:'',
                endPoint:'',
                bucketName:'',
                filePath:'chat'//聊天图片文件在阿里云存放的目录
            }
        });
# 监听事件
SFIM.listen({
            onTextMessage: (data)=> {
                console.log('收到消息', data);
            },
            onEmojiMessage: (data)=> {
                console.log('收到消息', data);
            },
            onImgMessage: (data)=> {
                console.log('收到消息', data);
            },
            onReadMessage: (data)=> {
                console.log('对方已读', data);
            },
            onConnect: ()=> {
                console.log('连接成功');
            },
            onDisconnect: ()=> {
                console.log('断开连接');
            },
        })

# 注册账号
SFIM.register('13888888888','123456','8',(data)=>{

},(err)=>{

})

# 登录聊天服务器
SFIM.login(this.state.account, this.state.pwd, (data)=> {
            console.log('登录成功',data)
        }, (err)=> {
            console.log('登录失败',err)
        })

# 设置昵称
SFIM.setNick(nick,(ret)=>{

},(err)=>{

})

# 设置头像
SFIM.setHeader(header,(ret)=>{

},(err)=>{

})

# 发送文本消息
var msg = SFIM.message(SFIMConfig.msg.text);
msg.text({
    msg:'要发送的消息',
    to:'对方的UID',
    suc:(data)=>{
        console.log('发送成功',data);
    },
    fail:(err)=>{
        console.log('发送失败',err);
    }
});
SFIM.send(msg);

# 发送表情消息
var msg = SFIM.message(SFIMConfig.msg.emoji);
msg.text({
    msg:'要发送的消息',
    to:'对方的UID',
    suc:(data)=>{
        console.log('发送成功',data);
    },
    fail:(err)=>{
        console.log('发送失败',err);
    }
});
SFIM.send(msg);

# 发送图片消息
var msg = SFIM.message(SFIMConfig.msg.img);
msg.text({
    imgPath:'图片地址',
    to:'对方的UID',
    uploadProgress:(progress)=>{

    },
    uploadFinish:(data)=>{

    },
    suc:(data)=>{
        console.log('发送成功',data);
    },
    fail:(err)=>{
        console.log('发送失败',err);
    }
});
SFIM.send(msg);


# 获取历史消息
SFIM.getHistory(this.lastMsgId, 10, (data)=> {
                console.log('获取历史', data)
            })


# 获取对话列表
SFIM.getChatList((data)=>{
    console.log('对话列表',data)
})