使用getParticipants方法你可以获取在一个聊天会话中参与者的列表。和正常的聊天一样,你可以发送文本或数据消息给你想发的每个聊天成员,还可以使用inviteContact方法来邀请新的成员。leave方法允许你离开一个聊天室并结束会话。

 

和正常聊天一样,你可以通过实现并注册一个IChatListener来监听聊天室消息。和监听聊天消息一样,你还可以对人员加入或离开聊天室作出反应。

 

接下来的框架代码显示了实现一个聊天监听者的实现:

 

IChatListener groupChatListener = new IChatListener.Stub() {

// Fired when a one-to-one chat becomes a group chat.

public void convertedToGroupChat(String oldJid,String groupChatRoom,long groupId)

throws RemoteException {

// TODO Notify user that the conversation is now a group chat.

}

 

// Fired when a new person joins a chat room.

public void participantJoined(String groupChatRoom, String nickname)

throws RemoteException {

// TODO Notify user that a new participant has joined the conversation.

}

 

// Fired when a participant leaves a chat room.

public void participantLeft(String groupChatRoom, String nickname)

throws RemoteException {

// TODO Notify user a chat participant left.

}

 

// Fired when the group chat is closed

public void chatClosed(String groupChatRoom) throws RemoteException {

// TODO Close the chat.

}

 

public void chatRead(String arg0) throws RemoteException { }

public void newMessageReceived(String from, String body) { }

};

相关文章:

  • 2021-07-07
  • 2021-05-08
  • 2021-08-24
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-11
  • 2022-01-01
  • 2021-07-23
  • 2021-04-10
  • 2021-08-16
相关资源
相似解决方案