当前位置:网站首页>Supplement the short board - Open Source im project openim about initialization / login / friend interface document introduction

Supplement the short board - Open Source im project openim about initialization / login / friend interface document introduction

2022-06-26 16:05:00 51CTO

OpenIM The construction of documents has been far behind the development , It is often criticized by developers , In the next week , We will focus on completing the documents , Make it easier for developers to access . because app sdk The bottom is go To achieve , So this article first writes a template and framework , In the next few minutes , There will be iOS、Android、Flutter、Uniapp、jssdk Colleagues add specific details , And update to the official website

 Make up the short board - Open source IM project OpenIM About initialization / Sign in / Introduction to friend interface document _openim

Initialization and login

Initialization and login success callback , Normal use OpenIM The premise of service

SDK

describe

[Login]

Sign in , If login is successful , You must log out to perform the login operation again

[Logout]

Log out

[GetLoginStatus]

Get login status , 101: Login successful , 102: Landing , 103: Login failed , 201: Log out

[GetLoginUser]

Get the current login user UserID, At this time, the user login status is unknown

[initSDK]

initialization SDK, Execute once throughout the life cycle , Login related monitoring is introduced as follows :

OpenIM And the caller use the listening callback mechanism , Exchange information with the caller , The login status is immediately transferred to the caller through asynchronous callback , Ensure that information is delivered in a timely manner without blocking its main thread .

Listening instructions

Log in and listen

Callback description

[OnConnecting]

Connecting , When connecting to the background ( Including reconnection ) Callback

[OnConnectSuccess]

Successful connection

[OnConnectFailed]

The connection fails , If the network connection fails, it will be reconnected , No reconnection in other cases

[OnKickedOffline]

Kicked offline , It may be caused by the multi terminal login policy , Or the background administrator forces him to log out

[OnUserTokenExpired]

testing token Overdue callback

Calling process

OpenIM The call process is divided into the following steps : (1) initialization : Execute once throughout the life cycle (2) Set listening : Including group listening , Friends listen , User monitoring , Message and session listening , These monitoring will be described in other chapters (3) Sign in : Perform other operations after the login callback succeeds , Otherwise, there may be an error that the resource loading is not completed (4) Send and receive messages ;

Friend management interface

OpenIM Provide relationship hosting , For example, friend application , agree! , And friend acquisition ,OpenIM Store friends locally on the client , Combined with the message notification mechanism , Call the background interface on demand , Ensure local and server data consistency . At the same time, the monitoring mechanism is used , Communicate data changes to the caller through asynchronous callbacks .OpenIM When sending and receiving messages , By default, you do not check your friends , You can modify it in the configuration file .OpenIM A good friend relationship is a two-way relationship ,A add to B After being a good friend , be A stay B In my friends list ,B Also in the A In my friends list ,A Delete B, Just delete A 's friends list , and B Your friends list is unaffected . Again , The blacklist is similar . ![1](C:\Users\Administrator\Desktop\OpenIM\ Related to the official website \ Technical articles \6-25\1.jpg)

SDK

describe

[GetDesignatedFriendsInfo]

Get the information of the specified friend

[GetFriendList]

Get a list of all your friends

[SearchFriends]

Search for friends by keyword

[CheckFriend]

Check if you are friends

[AddFriend]

Initiate a friend add request

[SetFriendRemark]

Set friend notes

[DeleteFriend]

Delete friends ( One way deletion )

[GetRecvFriendApplicationList]

Get the list of add friend applications I received

[GetSendFriendApplicationList]

Get the application list for adding friends initiated by me

[AcceptFriendApplication]

Agree to friend application

[RefuseFriendApplication]

Reject friend application

[SetFriendListener]

Set up friends 、 Blacklist related monitoring , be used for UI Layer senses data changes in real time and refreshes

Listening instructions

The function of friend listener : Caller sets friend monitoring , The change of friends' relationship will be through OpenIM The message mechanism synchronizes to online users who need to be aware in real time , Including the other end of the user , The caller performs relevant data processing according to the callback event . Such as user B stay Android Add users at the end A Good friends , user A( All online terminals ) received B Friend application for , be A call GetRecvFriendApplicationList Get the received friend application list , Refresh the interface . meanwhile , user B Other online terminals such as PC The client will also receive the notification ,B call GetSendFriendApplicationList Get the list of initiated friend applications , Refresh B List of friend applications sent out . Of course, you can also use the parameter information of the callback , Do incremental processing , Instead of getting a full list of friend applications . To the user B Apply to add users A For example

Friends and blacklist monitoring

describe

[OnFriendApplicationAdded]

Friend application list added , Active initiators and passive adders will receive

[OnFriendApplicationDeleted]

Friend application list delete , Active delegators will receive

[OnFriendApplicationAccepted]

Friend application is approved , Active initiators and passive adders will receive

[OnFriendApplicationRejected]

Friend request rejected , Active initiators and passive adders will receive

[OnFriendAdded]

Friends increase , When users' friends are added, they will receive

[OnFriendDeleted]

Friend deletion , Users will receive... When their friends are reduced

[OnFriendInfoChanged]

Friend information changes , User friend information ( Such as nicknames ) When you change, you will receive

[OnBlackAdded]

Blacklist added , When the user blacklist is added, you will receive

[OnBlackDeleted]

Remove the blacklist , When the user blacklist is reduced, you will receive

Project introduction

OpenIM Continue to lead open source IM field , With the support of developers , at present github star breakthrough 9k. In data leakage 、 Information leakage 、 The era of privacy abuse ,IM There is a strong demand for privatization deployment . among , The government and enterprises work together to IM Demand soared , With the iterative upgrading of information technology and the acceleration of the implementation and practice of the information innovation industry , The development potential of collaborative office software will be further released .“ Safe and controllable “ Gradually become the first element . For community dating , More and more privacy and security issues have been exposed , The privatization deployment ensures that the user data is not disclosed . OpenIM From the server to the client SDK Open source instant messaging (IM) Overall solution , Can easily replace third parties IM The cloud service , Create a chat 、 social contact 、 Office function app. ! Make up the short board - Open source IM project OpenIM About initialization / Sign in / Introduction to friend interface document _openim_02 github Address : https://github.com/OpenIMSDK/Open-IM-Server Developer center :https://doc.rentsoft.cn/#/

OpenIM The team

The founding team comes from senior IM Technical team , We are committed to creating service value with open source technology , Build lightweight 、 Highly available IM framework , Developers simply call SDK, You can build a variety of instant messaging and real-time audio and video interaction scenes in the application .OpenIM advantage : Open source , Security , reliable , Low cost . E-government, which attaches importance to information security , Enterprise collaborative office ,OpenIM They're all very good choices . Since its inception, the company has been “ Open source ” As a core strategy to promote , Open source fully embodies freedom 、 equality 、 Share the spirit of the Internet . OpenIM Invite global technology geeks to participate in technology optimization , Make it easy for developers to integrate , Let every application have IM function , At the same time, consider the access cost of the enterprise 、 Server resources and the most important data security and privacy .

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261537138483.html