RongCloud Server SDK in Go.
- New developers should use Server SDK v4. If you’re using an older version, retest before switching—–direct upgrades aren’t supported.
- Go Module file:
require github.com/rongcloud/server-sdk-go - Import:
import "github.com/rongcloud/server-sdk-go/sdk"
- v4 version:
require github.com/rongcloud/server-sdk-go/v4 - Import:
import "github.com/rongcloud/server-sdk-go/v4/sdk"
- Download/update to GOPATH:
go get -u github.com/rongcloud/server-sdk-go - Import:
import "github.com/rongcloud/server-sdk-go/sdk"
- See
rongcloud_test.gofor API call examples.
package main
import "fmt"
// Older version or non-Go Module usage
import "github.com/rongcloud/server-sdk-go/sdk"
// Go Module v4 usage
//import "github.com/rongcloud/server-sdk-go/v4/sdk"
func main() {
//Initialization must specify a data center
rc := sdk.NewRongCloud("appKey", "appSecret", REGION_BJ)
msg := sdk.TXTMsg{
Content: "hello",
Extra: "helloExtra",
}
err := rc.PrivateSend(
"userId",
[]string{"toUserId"},
"RC:TxtMsg",
&msg,
"",
"",
1,
0,
1,
0,
0,
)
fmt.Println(err)
}- Optimize HTTP connections for better performance.
sdk.WithMaxIdleConnsPerHost: Max active connections per host, default 100.sdk.WithTimeout: Connection timeout, default 10 seconds; minimum unit is seconds, e.g.,sdk.WithTimeout(30)sets it to 30 seconds.sdk.WithKeepAlive: Connection keepalive time, default 30 seconds; minimum unit is seconds, e.g.,sdk.WithKeepAlive(30)sets it to 30 seconds.rc.SetHttpTransport: Manually set the HTTP client.rc.GetHttpTransport: Get the current global HTTP client.
package main
import "fmt"
import "time"
import "net"
import "net/http"
import "github.com/rongcloud/server-sdk-go/sdk"
func main() {
// Method 1: Set during object creation
rc := sdk.NewRongCloud("appKey",
"appSecret",
//Initialization must specify a data center
REGION_BJ,
// Max active connections per host
sdk.WithMaxIdleConnsPerHost(100),
)
// Method 2: Custom HTTP client, set via the set method
dialer := &net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 30 * time.Second,
}
globalTransport := &http.Transport{
DialContext: dialer.DialContext,
MaxIdleConnsPerHost: 100,
}
rc.SetHttpTransport(globalTransport)
}| Module | Method name | Description | master |
|---|---|---|---|
| User information | UserRegister | Register, get token | √ |
| UserUpdate | Update user info | √ | |
| UserInfoGet | Get user info | √ | |
| OnlineStatusCheck | Check user online status | √ | |
| BlacklistAdd | Add to blocklist | √ | |
| BlacklistGet | Get blocklist | √ | |
| BlacklistRemove | Remove from blocklist | √ | |
| BlockAdd | Ban user | √ | |
| BlockGetList | Get banned user list | √ | |
| BlockRemove | Unban user | √ | |
| TagSet | Add user tag | √ | |
| TagBatchSet | Batch add user tags | √ | |
| TagGet | Get user tags | √ | |
| UserQuery | Query users with pagination (functional options) | √ | |
| UserDelUsers | Delete users in batch (up to 100 per request) | √ | |
| GroupMuteAdd | Add global group mute, user can’t send messages in any group | ||
| GroupMuteRemove | Remove global group mute | ||
| GroupMuteGetList | Get global group mute list | ||
| ChatRoomMuteAdd | Add global chatroom mute, user can’t send messages in any chatroom | ||
| ChatRoomMuteRemove | Remove global chatroom mute | ||
| ChatRoomMuteGetList | Get global chatroom mute list | ||
| UserDeactivate | Deactivate user | √ | |
| UserDeactivateQuery | Query deactivated users | √ | |
| UserReactivate | Reactivate deactivated users | √ | |
| Sensitive words | SensitiveAdd | Add sensitive word, takes effect in 2 hours | √ |
| SensitiveGetList | Get sensitive word list | √ | |
| SensitiveRemove | Remove sensitive word, supports batch removal, takes effect in 2 hours | √ | |
| Message sending | PrivateSend | Send private message | √ |
| PrivateSendTemplate | Send private template message | √ | |
| PrivateRecall | Recall private message | √ | |
| ChatRoomSend | Send chatroom message | √ | |
| ChatRoomBroadcast | Send chatroom broadcast message | √ | |
| GroupSend | Send group message | √ | |
| GroupSendMention | Send group @ message | √ | |
| GroupRecall | Recall group message | √ | |
| SystemSend | Send system message | √ | |
| SystemSendTemplate | Send system template message | √ | |
| SystemBroadcast | Send broadcast message, max 2 per hour, 3 per day. | √ | |
| Message history | HistoryGet | Get message history download URL | √ |
| HistoryRemove | Delete message history | √ | |
| ConversationMessageHistoryClean | Clean conversation history (functional options) | √ | |
| Broadcast push | PushSend | Send push, max 2 per hour, 3 per day. | √ |
| Group | GroupCreate | Create group | √ |
| GroupSync | Sync group relationships | √ | |
| GroupUpdate | Update group info | √ | |
| GroupGet | Get group info | √ | |
| GroupJoin | Invite users to group | √ | |
| GroupQuit | Quit group | √ | |
| GroupDismiss | Dismiss group | √ | |
| GroupMuteMembersAdd | Mute users in group | √ | |
| GroupMuteMembersRemove | Unmute users in group | √ | |
| GroupMuteMembersGetList | Get muted users in group | √ | |
| GroupMuteAllMembersAdd | Mute all group members | √ | |
| GroupMuteAllMembersRemove | Unmute all group members | √ | |
| GroupMuteAllMembersGetList | Get group mute list | √ | |
| GroupMuteWhiteListUserAdd | Add users to group mute allowlist | √ | |
| GroupMuteWhiteListUserRemove | Remove users from group mute allowlist | √ | |
| GroupMuteWhiteListUserGetList | Get group mute allowlist | √ | |
| Conversation do not disturb | ConversationMute | Mute conversation | √ |
| ConversationUnmute | Unmute conversation | √ | |
| ConversationGet | Get conversation mute status | √ | |
| Chatroom | ChatRoomCreate | Create chatroom | √ |
| ChatRoomDestroy | Destroy chatroom | √ | |
| ChatRoomGet | Get chatroom info | √ | |
| ChatRoomIsExist | Check if user is in chatroom | √ | |
| ChatRoomBlockAdd | Ban user from chatroom | √ | |
| ChatRoomBlockGetList | Get banned users in chatroom | √ | |
| ChatRoomBlockRemove | Unban user from chatroom | √ | |
| ChatRoomMuteMembersAdd | Mute users in chatroom | √ | |
| ChatRoomMuteMembersGetList | Get muted users in chatroom | √ | |
| ChatRoomMuteMembersRemove | Unmute users in chatroom | √ | |
| ChatRoomDemotionAdd | Add low-priority messages in chatroom | √ | |
| ChatRoomDemotionGetList | Get low-priority messages in chatroom | √ | |
| ChatRoomDemotionRemove | Remove low-priority messages in chatroom | √ | |
| ChatRoomDistributionStop | Stop chatroom message distribution | √ | |
| ChatRoomDistributionResume | Resume chatroom message distribution | √ | |
| ChatRoomKeepAliveAdd | Keep chatroom alive | √ | |
| ChatRoomKeepAliveRemove | Remove chatroom keepalive | √ | |
| ChatRoomKeepAliveGetList | Get keepalive chatrooms | √ | |
| ChatRoomWhitelistAdd | Add whitelist message types in chatroom | √ | |
| ChatRoomWhitelistRemove | Remove whitelist message types | √ | |
| ChatRoomWhitelistGetList | Get whitelist message types | √ | |
| ChatRoomUserWhitelistAdd | Add whitelist users in chatroom | √ | |
| ChatRoomUserWhitelistRemove | Remove whitelist users | √ | |
| ChatRoomUserWhitelistGetList | Get whitelist users | √ | |
| GroupSend | Send a group message | √ | |
| GroupSendMention | Send a group @ message | √ | |
| GroupRecall | Recall a group message | √ | |
| SystemSend | Send a system message | √ | |
| SystemSendTemplate | Send a system template message | √ | |
| SystemBroadcast | Broadcast a message, limited to 2 times per hour and 3 times per day per app. | √ | |
| Message history | HistoryGet | Get message history download URL | √ |
| HistoryRemove | Delete message history | √ | |
| GetPrivateHistoryMessage | Get one-to-one historical messages | √ | |
| GetGroupHistoryMessage | Get group historical messages | √ | |
| GetUltraGroupHistoryMessage | Get ultra group historical messages | √ | |
| GetChatroomHistoryMessage | Get chatroom historical messages | √ | |
| Broadcast push | PushSend | Send a push, combined with broadcast messages, limited to 2 times per hour and 3 times per day per app. | √ |
| Group | GroupCreate | Create a group | √ |
| GroupSync | Sync group relationships | √ | |
| GroupUpdate | Update group info | √ | |
| GroupGet | Get group info | √ | |
| GroupJoin | Invite users to join a group | √ | |
| GroupQuit | Quit a group | √ | |
| GroupDismiss | Dismiss a group | √ | |
| GroupMuteMembersAdd | Mute users in a group, preventing them from sending messages | √ | |
| GroupMuteMembersRemove | Unmute users in a group | √ | |
| GroupMuteMembersGetList | Get list of muted users in a group | √ | |
| GroupMuteAllMembersAdd | Mute all members in a group, preventing them from sending messages | √ | |
| GroupMuteAllMembersRemove | Unmute all members in a group | √ | |
| GroupMuteAllMembersGetList | Get list of muted groups | √ | |
| GroupMuteWhiteListUserAdd | Add users to group mute whitelist, allowing them to send messages even if the group is muted | √ | |
| GroupMuteWhiteListUserRemove | Remove users from group mute whitelist | √ | |
| GroupMuteWhiteListUserGetList | Get list of users in group mute whitelist | √ | |
| Conversation mute | ConversationMute | Mute a conversation | √ |
| ConversationUnmute | Unmute a conversation | √ | |
| ConversationGet | Get conversation mute status | √ | |
| Chat room | ChatRoomCreate | Create a chat room | √ |
| ChatRoomDestroy | Destroy a chat room | √ | |
| ChatRoomGet | Query chat room info | √ | |
| ChatRoomIsExist | Check if a user is in a chat room | √ | |
| ChatRoomBlockAdd | Block a user from a chat room, preventing them from joining or kicking them if already in the chat room | √ | |
| ChatRoomBlockGetList | Get list of blocked users in a chat room | √ | |
| ChatRoomBlockRemove | Unblock a user from a chat room | √ | |
| ChatRoomMuteMembersAdd | Mute a user in a chat room, preventing them from sending messages | √ | |
| ChatRoomMuteMembersGetList | Get list of muted users in a chat room | √ | |
| ChatRoomMuteMembersRemove | Unmute a user in a chat room | √ | |
| ChatRoomDemotionAdd | Add low-priority messages to a chat room, which may be discarded when the server is under heavy load | √ | |
| ChatRoomDemotionGetList | Get list of low-priority messages in a chat room | √ | |
| ChatRoomDemotionRemove | Remove low-priority messages from a chat room | √ | |
| ChatRoomDistributionStop | Stop chat room message distribution, preventing the server from sending messages after receiving them | √ | |
| ChatRoomKeepAliveAdd | Add keepalive chatroom, keepalive chatrooms won’t be automatically destroyed | √ | |
| ChatRoomKeepAliveRemove | Remove keepalive chatroom | √ | |
| ChatRoomKeepAliveGetList | Get keepalive chatroom list | √ | |
| ChatRoomWhitelistAdd | Add allowlist message type, allowlist message types won’t be discarded when server pressure is high due to a surge in message volume, ensuring message delivery | √ | |
| ChatRoomWhitelistRemove | Remove allowlist message type | √ | |
| ChatRoomWhitelistGetList | Get allowlist message type list | √ | |
| ChatRoomUserWhitelistAdd | Add allowlist user, messages sent by allowlist users won’t be discarded when server pressure is high due to a surge in message volume, ensuring message delivery | √ | |
| ChatRoomUserWhitelistRemove | Remove allowlist user | √ | |
| ChatRoomUserWhitelistGetList | Get allowlist user list | √ |