Gaming is no longer just a form of entertainment.
Follow [Rongyun Global Internet Communication Cloud] to learn more

As the closest track to the Metaverse, the game is not only the first launch scene for the integration of various immersive experience technologies, but also a hot spot for creators' economic explosion.

Mobile gaming is gaining momentum in people's online spending, and according to data.ai's 2022 Mobile Gaming Report, mobile gaming consumer spending will reach $116 billion in 2021 and keep growing at a decent rate. The first quarter of 2022 was approximately $22 billion, a 42% increase from the first quarter of 2020.

(Mobile gaming consumer spending continues to grow)

Consistent with consumer trends, game downloads ranked first, and casual games performed particularly well, with gamers downloading about 5.5 times more casual games than in 2018.

Game products have become more diversified in sub-categories, and opportunities for innovative gameplay and vertical tracks have begun to increase. And Unity is the key to the game that cannot be bypassed by game developers.

With the deep integration and development of games and social networking, game socialization is widely used in all game categories as an important means to improve game stickiness and user retention.

Recently, Rongyun Unity SDK 5.1 was officially released, focusing on game scenarios, allowing developers to quickly access instant messaging and real-time audio and video functions in the game.

Rongyun Unity SDK introduction and scope of application

Rongyun Unity SDK features:
① Cross-platform, write and run on multiple platforms at one time. Save labor costs and facilitate maintenance.

② Support Raw Image and MeshRender rendering methods, you can freely choose to perform video rendering in UGUI or any 3D scene.

③ Simple and clear interface design, quick access in 30 seconds, and the access code does not exceed 15 lines.

④ Strong version compatibility, supports most Unity versions.

⑤ Multi-scene support, based on personalized scenes, select the applicable SDK, audio and video, pure audio SDK for you to choose.

Applicable games and their features:

Almost all chess and card games such as Mahjong, Gobang, Checkers, and Beast chess, as well as almost all leisure and puzzle games such as one-stop, billiards, Lianliankan, etc., can be blessed with communication capabilities by accessing the Rongyun SDK, providing players with a high level of communication capabilities. High-quality, low-latency interactive experience. Their communication scenarios are characterized by:

① There is only one RTC room during the game, and all personnel are in the same room;

② Players subscribe to other people's audio by default;

③ Players cannot control the microphone switches of other players, but can only turn off their own microphones;

④ Players can selectively listen to the audio of some players, and can choose to block the unfriendly audio.

Communication in the game:

① IM: Single chat, chat room; text messages, expressions, emoji, etc. The logic of sending messages during the game is as follows:

  • After matching with the opponent, add both the player of the player and the player of the opponent to the same chat room;
  • In the game, the chat room is in a keep alive state. After the game is over, both the player and the opponent player will be kicked out of the room, and the room will be destroyed (if there is another round, it will not be the end of the game).

② RTC: 1V1 voice; random match, invite friends, etc. The voice logic during the game is:

  • After matching with the opponent, add the player of the player and the player of the opponent to the same RTC room, and the microphone and earpiece/speaker are turned on by default;
  • Players on this side can turn off their own microphones, and the other side will not be able to hear their own speech;
  • Players on this side can turn off their own earpieces/speakers, and they will not hear the other party's speech;
  • After the game is over, the default call ends, the player on the side and the player on the other side are kicked out of the room, and the room is destroyed (if there is another round directly, the game is not over).

Rongyun Unity SDK access method and related interfaces

Rongyun Unity SDK access method:

① Directly integrate the Unity RTCLib SDK and Unity IMLib SDK of Rongyun into the game project. Android and iOS can directly call the Unity interface encapsulated by the SDK to realize in-game message and voice requirements;

② Integrate the native IMLib SDK and RTCLib SDK of Rongyun's iOS and Android respectively. When implementing in-game messages and voice, iOS and Android need to call their respective IMLib SDK and RTCLib SDK interfaces to implement it.

Involved interface:

① Create a chat room

If the chat room is not created, the SDK will create the chat room and join it, if it has been created, join it directly.

 // 创建聊天室
String chatRoomId = "聊天室 ID";
int defMessageCount = 50;
RCIMClient.Instance.JoinChatRoom(chatRoomId, (RCErrorCode code) => {
    // code : 错误码
}, defMessageCount);

② Join the created chat room

 // 加入聊天室
String chatroomId = "聊天室 ID";
int defMessageCount = 50;
RCIMClient.Instance.JoinExistChatRoom(chatroomId, (RCErrorCode code) => {
    // code : 错误码
}, defMessageCount);

③ Get the history message of the chat room

 // 获取聊天室历史消息
var conversationType = RCConversationType.ChatRoom;
int lastMessageId = -1;
final int count = 10;
final String targetId = "聊天室 ID";
final long recordTime = 0;
// 首先加载本地聊天室消息
var localMsgList = await RCIMClient.Instance.GetHistoryMessages(conversationType, targetId, lastMessageId, count);
if (localMsgList != null) {
    // 展示本地聊天室消息
    recordTime = localMsgList.Last().SentTime;
}
// 本地消息加载完毕,再获取远端服务器消息
RCIMClient.Instance.GetChatRoomHistoryMessages(targetId, recordTime, count, true,
    (code, chatRoomHistoryMessages) => {
    // code: 状态码,0 成功
    // chatRoomHistoryMessages: 聊天室远端历史消息
});

④ Get chat room properties

 // 获取聊天室属性
String chatRoomId = "聊天室 ID";
RCIMClient.Instance.GetChatRoomAllEntries(chatRoomId, 
    (RCErrorCode code, IDictionary<String, String> entries) {
    // entries: 聊天室属性
    // code: 状态码,0 成功
});

⑤ Set chat room properties

 // 设置聊天室属性
String chatRoomId = "聊天室 ID";
String key = "name";
String value = "融融";
bool sendNotification = true;
bool isAutoDel = false;
String notificationExtra = "通知消息扩展";
RCIMClient.Instance.ForceSetChatRoomEntry(chatRoomId, key, value, sendNotification, isAutoDel, notificationExtra, (code) => {
    // code: 状态码,0 成功
});

⑥ Delete chat room properties

 // 订阅⽤户 
int Subscribe(String userId, RCRTCMediaType type); 
int Subscribe(IList<String> userIds, RCRTCMediaType type);

⑦ Exit chat room properties

 // 退出聊天室
String chatroomId = "聊天室 ID";
RCIMClient.Instance.QuitChatRoom(chatroomId, (RCErrorCode code) => {
    // code: 错误码
});

Join the room

 // 加⼊RTC房间 
RCRTCRoomSetup setup = RCRTCRoomSetup.Builder.Create().WithRole(RCRTCRole.LIVE_BROADCASTER).Build(); 
Engine.JoinRoom(RoomId, setup);

⑨ Microphone control <br>The host can turn on or off the local microphone in the room

 // 是否启⽤⻨克⻛ 
int EnableMicrophone(bool enable);

⑩ Speaker Control <br>The anchor can switch the playback setting of the sound, speaker or earpiece in the room. This method is called when a peripheral device is connected, such as a bluetooth speaker, etc. and returns -1.

 // 是否启⽤扬声器 
int EnableSpeaker(bool enable);

⑪ Publish local audio <br>After joining the RTC room successfully, publish the local audio

 Engine.Publish(RCRTCMediaType.AUDIO);

⑫ Unpublish local audio

 Engine.Unpublish(RCRTCMediaType.AUDIO);

⑬ Subscribers

 // 订阅⽤户 
int Subscribe(String userId, RCRTCMediaType type); 
int Subscribe(IList<String> userIds, RCRTCMediaType type);

⑭ Unsubscribe user

 // 取消订阅⽤户 
int Unsubscribe(String userId, RCRTCMediaType type); 
int Unsubscribe(IList<String> userIds, RCRTCMediaType type);

⑮ Leave the room

 Engine.LeaveRoom();

融云RongCloud
82 声望1.2k 粉丝

因为专注,所以专业