Skip to content

openimsdk/open-im-sdk-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

59 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Dotnet SDK for OpenIM ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿ’ฌ

Use this SDK to add instant messaging capabilities to your Unity Game. By connecting to a self-hosted OpenIM server, you can quickly integrate instant messaging capabilities into your app with just a few lines of code.

The underlying SDK core is implemented in openim-sdk-cpp.

Documentation ๐Ÿ“š

Visit https://docs.openim.io/ for detailed documentation and guides.

For the SDK reference, see https://docs.openim.io/sdks/quickstart/unity.

Installation ๐Ÿ’ป

Add Pacakge

dotnet add package open-im-sdk --version 1.0.2

dotnet pack

dotnet pack open-im-sdk.csproj --configuration Release

Usage ๐Ÿš€

The following examples demonstrate how to use the SDK.

Importing the SDK and initialize

using OpenIM.IMSDK;
using OpenIM.IMSDK.Listener;

Initialize

var config = new IMConfig()
{
    PlatformID = (int)PlatformID,
    ApiAddr = Config.APIAddr,
    WsAddr = Config.WsAddr,
    DataDir = Path.Combine(AppContext.BaseDirectory, Config.DataDir),
    LogLevel = Config.LogLevel,
    IsLogStandardOutput = Config.IsLogStandardOutput,
    LogFilePath = Path.Combine(AppContext.BaseDirectory, Config.LogFilePath),
    IsExternalExtensions = Config.IsExternalExtensions,
};
var suc = IMSDK.InitSDK(config, new ConnListener());

Set Listener

Note1: You need to set up the listeners first and then log in.

IMSDK.SetConversationListener(IConversationListener l);
IMSDK.SetGroupListener(IGroupListener l);
IMSDK.SetFriendShipListener(IFriendShipListener l);
IMSDK.SetFriendShipListener(IFriendShipListener l);
IMSDK.SetAdvancedMsgListener(IAdvancedMsgListener l);
IMSDK.SetUserListener(IUserListener l);
IMSDK.SetBatchMsgListener(IBatchMsgListener l)

Login

var status = IMSDK.GetLoginStatus();
if (status == LoginStatus.Empty || status == LoginStatus.Logout)
{
    IMSDK.Login(userId, token, (suc, err, errMsg) =>
    {
        if (suc)
        {
            Debug.Log("Login UserId:" + IMSDK.GetLoginUserId());
            GetData();
        }
        else
        {
            {
                Debug.Log("Login Failed :" + errMsg);
            }
        }
    });
}
else if (status == LoginStatus.Logged)
{
    Debug.Log("Login UserId:" + IMSDK.GetLoginUserId());
    GetData();
}

Logout

// Log out the currently logged in user
IMSDK.Logout((suc,err,errMsg)=>{

})
// exit sdk
IMSDK.UnInitSDK();

To log into the IM server, you need to create an account and obtain a user ID and token. Refer to the access token documentation for details.

Examples ๐ŸŒŸ

You can find a demo that uses the SDK in the open-im-dotnet-demo repository.

Community ๐Ÿ‘ฅ

Community Meetings ๐Ÿ“†

We want anyone to get involved in our community and contributing code, we offer gifts and rewards, and we welcome you to join us every Thursday night.

Our conference is in the OpenIM Slack ๐ŸŽฏ, then you can search the Open-IM-Server pipeline to join

We take notes of each biweekly meeting in GitHub discussions, Our historical meeting notes, as well as replays of the meetings are available at Google Docs ๐Ÿ“‘.

Who are using OpenIM ๐Ÿ‘€

Check out our user case studies page for a list of the project users. Don't hesitate to leave a ๐Ÿ“comment and share your use case.

License ๐Ÿ“„

This software is licensed under a dual-license model:

  • The GNU Affero General Public License (AGPL), Version 3 or later; OR
  • Commercial license terms from OpenIMSDK.

If you wish to use this software under commercial terms, please contact us at: [email protected]

For more information, see: https://www.openim.io/en/licensing

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages