Chatroom

6.1 Get the StarRtc.StarChatSDK instance and implement the callback function

var chatInnerCallback = function (data, status) {
switch (status){
case "connect success":
//connect success
break;
case "connect failed":
case "connect closed":
//connect failed
break;
case "onChatRoomMessage":
{
//Receive chat room message
switch(data.type)
{
case "createChatRoom":
//Create a chatroom
//data.status == "success"means success,and "data.chatroomId" is the chat room Id
break;
case "deleteChatRoom":
//delete the chatroom
//data.status == "success" means success
break;
case "joinChatRoom":
//join the chatroom
//data.status == "success"means success
break;
case "recvChatPrivateMsg":
//Receive chat room private message
case "recvChatMsg":
//Receive chat room message
//Message structure
//data = {
// "fromUserId": message source
// "msg": Message structure
//}
//msg structure
//msg = {
// "fromId": message source,Use this id when displaying
// "targetId": Message receiver
// "time": Timestamp
// "msgIndex": Message sequence number
// "type": type
// "code": Message control type code
// "contentData": Message content
//};
break;
case "chatroomUserKicked":
//Received a message that you are kicked out of the chat room
break;
case "getRoomOnlineNum":
//Received a message of getting the number of chat rooms,data.onlineNum:number of online users
break;
case "serverErr":
//Receive error message of server
//Data.msg is the specific cause of the error
break;

}
}
break;

}
}

/**
* Constructor
* @param _oper Operation type: new, create; open, join
* @param _userCallback callback
* @param _userData Store information about the chat room(id,name,creator),and the structure is{"roomInfo":{"id":"", "name":"", "creator":""}}
* @param _starUser User Info(见StarRtc.StarUserInfo)
* @param _starConfig Star configuration(Reference StarRtc.StarConfig)
*/
StarRtc.StarChatSDK = function (_oper, _userCallback, _userData, _liveType, _starUser, _starConfig)

6.2 StarRtc.StarChatSDK API Description

/**
* Coonect to the room
*/
StarRtc.StarChatSDK.sigConnect = function ()

/**
* Disconnect to the room
* @param flag The flag of Whether to disconnect actively, which is used to determine reconnection
*/
StarRtc.StarChatSDK.sigDisconnect = function (_flag)

/**
* Create a room
*/
StarRtc.StarChatSDK.createNew = function ()

* Send chat room message
* @param msg message
*/
StarRtc.StarChatSDK.sendChatMsg = function (msg)

/**
* Send chat room private message
* @param toUserId the user ID the meaasge will be sent to
* @param msg message
*/
StarRtc.StarChatSDK.sendChatPrivateMsg = function (toUserId, msg)

/**
* Send chat room private chat control message
* @param toUserId The message who will be sent to
* @param msg meesage
* @param code control code
*/
StarRtc.StarChatSDK.sendChatCtrlPrivateMsg = function (toUserId, msg, code)

/**
* kick out the user
* @param kickOutUserId the user ID who will be kicked out
*/
StarRtc.StarChatSDK.kickOutUser = function (kickOutUserId)

/**
* Speaking not allowed in the room
* @param banUserId the user ID of who is speaking not allowed
* @param banTime the time duration of speaking not allowed
*/
StarRtc.StarChatSDK.banToSendMsg = function (banUserId, banTime)

/**
* Get the number of online users in the chat room
*/
StarRtc.StarChatSDK.getRoomOnlineNum = function ()

/**
* Delete the current room
*/
StarRtc.StarChatSDK.deleteCurrRoom = function ()

/**
* Join the room
*/
StarRtc.StarChatSDK.joinRoom = function ()

/**
* leave the room
*/
StarRtc.StarChatSDK.leaveRoom = function ()

/**
* Get the disconnect satus:active or passive?
*/
StarRtc.StarChatSDK.activeDisconnect = function ()