- Android
- iOS
- JavaScript
- Flutter
- ReactNative
- HarmonyOS
Chatroom messages are returned through the shared message listener. You can register multiple chatroom join and leave listeners.
JIM.getInstance().getChatroomManager().addListener("main", this);
@Override
public void onChatroomJoin(String chatroomId) {
Log.i("TAG", "onChatroomJoin, chatroomId is " + chatroomId);
}
@Override
public void onChatroomQuit(String chatroomId) {
Log.i("TAG", "onChatroomQuit, chatroomId is " + chatroomId);
}
@Override
public void onChatroomJoinFail(String chatroomId, int errorCode) {
Log.i("TAG", "onChatroomJoinFail, chatroomId is " + chatroomId + ", errorCode is " + errorCode);
}
@Override
public void onChatroomQuitFail(String chatroomId, int errorCode) {
Log.i("TAG", "onChatroomQuitFail, chatroomId is " + chatroomId + ", errorCode is " + errorCode);
}
@Override
public void onChatroomKick(String chatroomId) {
Log.i("TAG", "onChatroomKick, chatroomId is " + chatroomId);
}
@Override
public void onChatroomDestroy(String chatroomId) {
Log.i("TAG", "onChatroomDestroy, chatroomId is " + chatroomId);
}
You can register multiple chatroom attribute-change listeners.
JIM.getInstance().getChatroomManager().addAttributesListener("main", this);
@Override
public void onAttributesUpdate(String chatroomId, Map<String, String> attributes) {
Log.i("TAG", "onAttributesUpdate, chatroomId is " + chatroomId + ", count is " + attributes);
}
@Override
public void onAttributesDelete(String chatroomId, Map<String, String> attributes) {
Log.i("TAG", "onAttributesDelete, chatroomId is " + chatroomId + ", count is " + attributes);
}
Chatroom messages are returned through the shared message listener. You can register multiple chatroom join and leave listeners.
[JIM.shared.chatroomManager addDelegate:self];
- (void)chatroomDidJoin:(NSString *)chatroomId {
NSLog(@"chatroomDidJoin, chatroomId is %@", chatroomId);
}
- (void)chatroomDidQuit:(NSString *)chatroomId {
NSLog(@"chatroomDidQuit, chatroomId is %@", chatroomId);
}
- (void)chatroomJoinFail:(NSString *)chatroomId errorCode:(JErrorCode)errorCode {
NSLog(@"chatroomJoinFail, chatroomId is %@, errorCode is %ld", chatroomId, errorCode);
}
- (void)chatroomQuitFail:(NSString *)chatroomId errorCode:(JErrorCode)errorCode {
NSLog(@"chatroomQuitFail, chatroomId is %@, errorCode is %ld", chatroomId, errorCode);
}
- (void)chatroomDidDestroy:(NSString *)chatroomId {
NSLog(@"chatroomDidDestroy, chatroomId is %@", chatroomId);
}
- (void)chatroomDidKick:(NSString *)chatroomId {
NSLog(@"chatroomDidKick, chatroomId is %@", chatroomId);
}
You can register multiple chatroom attribute-change listeners.
[JIM.shared.chatroomManager addAttributesDelegate:self];
- (void)attributesDidDelete:(NSDictionary<NSString *,NSString *> *)attributes forChatroom:(NSString *)chatroomId {
NSLog(@"attributesDidDelete, count is %ld, chatroom is %@", attributes.count, chatroomId);
}
- (void)attributesDidUpdate:(NSDictionary<NSString *,NSString *> *)attributes forChatroom:(NSString *)chatroomId {
NSLog(@"attributesDidUpdate, count is %ld, chatroom is %@", attributes.count, chatroomId);
}
Not supported.
Chatroom listeners include attribute changes and member changes. Chatroom messages are returned through the shared message listener.
// current-user rejoin event; the SDK automatically rejoins the chatroom after the network recovers
jim.on(Event.CHATROOM_USER_REJOINED, (user) => {
// user => { id: '10002', name: 'xiaokele' }
});
// current user joined the room
jim.on(Event.CHATROOM_USER_JOINED, (user) => {
// user => { id: '10002', name: 'xiaokele' }
});
// current user left the room
jim.on(Event.CHATROOM_USER_QUIT, (user) => {
// user => { id: '10002', name: 'xiaokele' }
});
// chatroom-member join event
jim.on(Event.CHATROOM_MEMBER_JOINED, (member) => {
// member => { id: '10001', name: 'xiaoshan' }
});
// chatroom-member leave event
jim.on(Event.CHATROOM_MEMBER_QUIT, (member) => {
// member => { id: '10001', name: 'xiaoshan' }
});
// chatroom-destroyed event; use the Server API to destroy a chatroom
jim.on(Event.CHATROOM_DESTROYED, (chatroom) => {
// chatroom => { id: 'chatroom1001' }
});
// chatroom-attribute deletion notification
jim.on(Event.CHATROOM_ATTRIBUTE_DELETED, (chatroom) => {
console.log('chatroom attributes deleted', chatroom);
/*
chatroom =>
{
id: 'chatroom1001',
attributes:[{ key: 'name' }]
}
*/
});
// chatroom-attribute update notification
jim.on(Event.CHATROOM_ATTRIBUTE_UPDATED, (chatroom) => {
console.log('chatroom attributes updated', chatroom);
/*
chatroom =>
{
id: 'chatroom1001',
attributes:[{ key: 'name', value: 'xiaoshan', userId: 'ID of the user who updated the key' }]
}
*/
});
Chatroom messages are returned through the shared message listener. You can register multiple chatroom join and leave listeners.
import JuggleIM from 'juggleim-rnsdk';
// joined the chatroom successfully
JuggleIM.onChatroomJoin = (chatroomId: string) => {
console.log('onChatroomJoin, chatroomId is', chatroomId);
};
// left the chatroom successfully
JuggleIM.onChatroomQuit = (chatroomId: string) => {
console.log('onChatroomQuit, chatroomId is', chatroomId);
};
// failed to join the chatroom
JuggleIM.onChatroomJoinFail = (chatroomId: string, errorCode: number) => {
console.log('onChatroomJoinFail, chatroomId is', chatroomId, ', errorCode is', errorCode);
};
// failed to leave the chatroom
JuggleIM.onChatroomQuitFail = (chatroomId: string, errorCode: number) => {
console.log('onChatroomQuitFail, chatroomId is', chatroomId, ', errorCode is', errorCode);
};
// removed from the chatroom
JuggleIM.onChatroomKick = (chatroomId: string) => {
console.log('onChatroomKick, chatroomId is', chatroomId);
};
// chatroom destroyed
JuggleIM.onChatroomDestroy = (chatroomId: string) => {
console.log('onChatroomDestroy, chatroomId is', chatroomId);
};
You can register multiple chatroom attribute-change listeners.
// chatroom attributes updated
JuggleIM.onChatroomAttributesUpdate = (chatroomId: string, attributes: Record<string, string>) => {
console.log('onAttributesUpdate, chatroomId is', chatroomId, ', attributes is', attributes);
};
// chatroom attributes deleted
JuggleIM.onChatroomAttributesDelete = (chatroomId: string, attributes: Record<string, string>) => {
console.log('onAttributesDelete, chatroomId is', chatroomId, ', attributes is', attributes);
};
Chatroom messages are returned through the shared message listener. You can register multiple chatroom join and leave listeners.
// joined the chatroom successfully
JuggleIm.instance.getChatroomManager().onChatroomJoin = (chatroomId) => {
console.log('onChatroomJoin, chatroomId is', chatroomId);
};
// left the chatroom successfully
JuggleIm.instance.getChatroomManager().onChatroomQuit = (chatroomId) => {
console.log('onChatroomQuit, chatroomId is', chatroomId);
};
// failed to join the chatroom
JuggleIm.instance.getChatroomManager().onChatroomJoinFail = (chatroomId, errorCode) => {
console.log('onChatroomJoinFail, chatroomId is', chatroomId, ', errorCode is', errorCode);
};
// failed to leave the chatroom
JuggleIm.instance.getChatroomManager().onChatroomQuitFail = (chatroomId, errorCode) => {
console.log('onChatroomQuitFail, chatroomId is', chatroomId, ', errorCode is', errorCode);
};
// removed from the chatroom
JuggleIm.instance.getChatroomManager().onChatroomKick = (chatroomId) => {
console.log('onChatroomKick, chatroomId is', chatroomId);
};
// chatroom destroyed
JuggleIm.instance.getChatroomManager().onChatroomDestroy = (chatroomId) => {
console.log('onChatroomDestroy, chatroomId is', chatroomId);
};
You can register multiple chatroom attribute-change listeners.
// chatroom attributes updated
JuggleIm.instance.getChatroomManager().onAttributesUpdate = (chatroomId, attributes) => {
console.log('onAttributesUpdate, chatroomId is', chatroomId, ', attributes is', attributes);
};
// chatroom attributes deleted
JuggleIm.instance.getChatroomManager().onAttributesDelete = (chatroomId, attributes) => {
console.log('onAttributesDelete, chatroomId is', chatroomId, ', attributes is', attributes);
};