ChatRoom

public class ChatRoom : LinphoneObject

A chat room is the place where ChatMessage are exchanged. To create (or find) a ChatRoom, you first need a ChatRoomParams object. A chat room is uniquely identified by it’s local and remote SIP addresses, meaning you can only have one chat room between two accounts (unless the backend is FlexisipChat). Then you can call Core.searchChatRoom() or Core.createChatRoom(). Be careful as a FlexisipChat backend ChatRoom will be created asynchronously, so make sure you add a LinphoneChatRoomCbs to the returned object to be notified when it will be in state Created. All chat rooms are loaded from database when the Core starts, and you can get them using Core.getChatRooms(). This method doesn’t return empty chat rooms nor ones for which the local address doesn’t match an existing ProxyConfig identity, unless you specify otherwise in the [misc] section of your configuration file by setting hide_empty_chat_rooms=0 and/or hide_chat_rooms_from_removed_proxies=0.

  • Undocumented

    Declaration

    Swift

    public static func getSwiftObject(cObject: OpaquePointer) -> ChatRoom
  • Undocumented

    Declaration

    Swift

    public var getCobject: OpaquePointer? { get }
  • State is used to indicate the current state of a chat room.

    See more

    Declaration

    Swift

    public enum State : Int
  • A chat room is the place where ChatMessage are exchanged. To create (or find) a ChatRoom, you first need a ChatRoomParams object. A chat room is uniquely identified by it’s local and remote SIP addresses, meaning you can only have one chat room between two accounts (unless the backend is FlexisipChat). Then you can call Core.searchChatRoom() or Core.createChatRoom(). Be careful as a FlexisipChat backend ChatRoom will be created asynchronously, so make sure you add a LinphoneChatRoomCbs to the returned object to be notified when it will be in state Created. All chat rooms are loaded from database when the Core starts, and you can get them using Core.getChatRooms(). This method doesn’t return empty chat rooms nor ones for which the local address doesn’t match an existing ProxyConfig identity, unless you specify otherwise in the [misc] section of your configuration file by setting hide_empty_chat_rooms=0 and/or hide_chat_rooms_from_removed_proxies=0.

    Declaration

    Swift

    public func addDelegate(delegate: ChatRoomDelegate)
  • A chat room is the place where ChatMessage are exchanged. To create (or find) a ChatRoom, you first need a ChatRoomParams object. A chat room is uniquely identified by it’s local and remote SIP addresses, meaning you can only have one chat room between two accounts (unless the backend is FlexisipChat). Then you can call Core.searchChatRoom() or Core.createChatRoom(). Be careful as a FlexisipChat backend ChatRoom will be created asynchronously, so make sure you add a LinphoneChatRoomCbs to the returned object to be notified when it will be in state Created. All chat rooms are loaded from database when the Core starts, and you can get them using Core.getChatRooms(). This method doesn’t return empty chat rooms nor ones for which the local address doesn’t match an existing ProxyConfig identity, unless you specify otherwise in the [misc] section of your configuration file by setting hide_empty_chat_rooms=0 and/or hide_chat_rooms_from_removed_proxies=0.

    Declaration

    Swift

    public func removeDelegate(delegate: ChatRoomDelegate)
  • Converts a State enum to a string.

    Declaration

    Swift

    public static func stateToString(state: ChatRoom.State) -> String

    Parameters

    state

    a State to convert to string

    Return Value

    the string representation of the State

  • Gets the current call associated to this chatroom if any To commit a message, use linphone_chat_room_send_message

    Declaration

    Swift

    public var call: Call? { get }

    Return Value

    Call or nil.

  • Get the capabilities of a chat room.

    Declaration

    Swift

    public var capabilities: UInt { get }

    Return Value

    The capabilities of the chat room (as a LinphoneChatRoomCapabilitiesMask)

  • When realtime text is enabled CallParams.realtimeTextEnabled(), LinphoneCoreIsComposingReceivedCb is call everytime a char is received from peer. At the end of remote typing a regular ChatMessage is received with committed data from LinphoneCoreMessageReceivedCb.

    Declaration

    Swift

    public var char: UInt32 { get }

    Return Value

    RFC 4103/T.140 char

  • Gets the list of participants that are currently composing.

    Declaration

    Swift

    public var composingAddresses: [Address] { get }

    Return Value

    List of addresses that are in the is_composing state.

  • Get the conference address of the chat room.

    Declaration

    Swift

    public var conferenceAddress: Address? { get set }

    Return Value

    The conference address of the chat room or nil if this type of chat room is not conference based.

  • Returns back pointer to Core object.

    Declaration

    Swift

    public var core: Core? { get }

    Return Value

    the Core object this chat room is attached to.

  • Return the creation time for the chat room.

    Declaration

    Swift

    public var creationTime: time_t { get }

    Return Value

    the time at which the chat room was created

  • Gets the current LinphoneChatRoomCbs. This is meant only to be called from a callback to be able to get the user_data associated with the LinphoneChatRoomCbs that is calling the callback.

    Declaration

    Swift

    public var currentDelegate: ChatRoomDelegate? { get }

    Return Value

    The LinphoneChatRoomCbs that has called the last callback

  • Returns current parameters associated with the chat room. This is typically the parameters passed at chat room chat_roomeation to linphone_core_chat_roomeate_chat_room() or some default parameters if no ChatRoomParams was explicitely passed during chat room chat_roomeation.

    Declaration

    Swift

    public var currentParams: ChatRoomParams? { get }

    Return Value

    the current ChatRoomParams parameters.

  • Returns whether or not the ephemeral message feature is enabled in the chat room.

    Declaration

    Swift

    public var ephemeralEnabled: Bool { get set }

    Return Value

    true if ephemeral is enabled, false otherwise.

  • Get lifetime (in seconds) for all new ephemeral messages in the chat room. After the message is read, it will be deleted after “time” seconds. - See also: ephemeralEnabled()

    Declaration

    Swift

    public var ephemeralLifetime: Int { get set }

    Return Value

    the ephemeral lifetime (in secoonds)

  • Get the ephemeral mode of the chat room.

    See

    See also: ephemeralEnabled()

    Declaration

    Swift

    public var ephemeralMode: ChatRoomEphemeralMode { get set }

    Return Value

    the ephemeral mode ChatRoomEphemeralMode

  • Gets the number of events in a chat room.

    Declaration

    Swift

    public var historyEventsSize: Int { get }

    Return Value

    the number of events.

  • Gets the number of messages in a chat room.

    Declaration

    Swift

    public var historySize: Int { get }

    Return Value

    the number of messages.

  • Returns whether or not a ChatRoom has at least one ChatMessage or not.

    Declaration

    Swift

    public var isEmpty: Bool { get }

    Return Value

    true if there are no ChatMessage, false otherwise.

  • Return whether or not a message can be sent using this chat room. A chat room may be read only until it’s created, or when it’s a group you have left.

    Declaration

    Swift

    public var isReadOnly: Bool { get }

    Return Value

    true if a chat message can’t be sent in it, false otherwise.

  • Tells whether the remote is currently composing a message.

    Declaration

    Swift

    public var isRemoteComposing: Bool { get }

    Return Value

    true if the remote is currently composing a message, false otherwise.

  • Gets the last chat message sent or received in this chat room.

    Declaration

    Swift

    public var lastMessageInHistory: ChatMessage? { get }

    Return Value

    the latest ChatMessage or nil if no message.

  • Return the last updated time for the chat room.

    Declaration

    Swift

    public var lastUpdateTime: time_t { get }

    Return Value

    the last updated time

  • Get the local address associated to this chat room.

    Declaration

    Swift

    public var localAddress: Address? { get }

    Return Value

    The local address.

  • me

    Get the participant representing myself in the chat room.

    Declaration

    Swift

    public var me: Participant? { get }

    Return Value

    The participant representing myself in the conference or nil if me is not set.

  • Get the number of participants in the chat room (that is without ourselves).

    Declaration

    Swift

    public var nbParticipants: Int { get }

    Return Value

    The number of participants in the chat room

  • Get the list of participants of a chat room.

    Declaration

    Swift

    public var participants: [Participant] { get }

    Return Value

    A of the participants

  • Get the peer address associated to this chat room.

    Declaration

    Swift

    public var peerAddress: Address? { get }

    Return Value

    The peer address.

  • Get the security level of a chat room.

    Declaration

    Swift

    public var securityLevel: ChatRoomSecurityLevel { get }

    Return Value

    The current ChatRoomSecurityLevel of the chat room

  • Get the state of the chat room.

    Declaration

    Swift

    public var state: ChatRoom.State { get }

    Return Value

    The current State of the chat room

  • Get the subject of a chat room.

    Declaration

    Swift

    public var subject: String { get set }

    Return Value

    The subject of the chat room.

  • Gets all unread messages for this chat room, sorted from oldest to most recent.

    Declaration

    Swift

    public var unreadHistory: [ChatMessage] { get }

    Return Value

    A list of unread chat messages.

  • Gets the number of unread messages in the chatroom.

    Declaration

    Swift

    public var unreadMessagesCount: Int { get }

    Return Value

    the number of unread messages.

  • Retrieve the user pointer associated with the chat room.

    Declaration

    Swift

    public var userData: UnsafeMutableRawPointer? { get set }

    Return Value

    The user pointer associated with the chat room.

  • Add a participant to a chat room. This may fail if this type of chat room does not handle participants. Use canHandleParticipants() to know if this chat room handles participants.

    Declaration

    Swift

    public func addParticipant(addr: Address)

    Parameters

    addr

    The address of the participant to add to the chat room

  • Add several participants to a chat room at once. This may fail if this type of chat room does not handle participants. Use canHandleParticipants() to know if this chat room handles participants.

    Declaration

    Swift

    public func addParticipants(addresses: [Address]) -> Bool

    Parameters

    addresses

    The participants to add.

    Return Value

    true if everything is OK, false otherwise

  • Allow cpim on a basic chat room .

    Declaration

    Swift

    public func allowCpim()
  • Allow multipart on a basic chat room .

    Declaration

    Swift

    public func allowMultipart()
  • Tells whether a chat room is able to handle participants.

    Declaration

    Swift

    public func canHandleParticipants() -> Bool

    Return Value

    true if the chat room can handle participants, false otherwise

  • Notifies the destination of the chat message being composed that the user is typing a new message.

    Declaration

    Swift

    public func compose()
  • Creates an empty message attached to the given chat room.

    Declaration

    Swift

    public func createEmptyMessage() throws -> ChatMessage

    Return Value

    a new ChatMessage

  • Creates a message attached to the given chat room with a particular content. Use linphone_chat_room_send_message to initiate the transfer

    Declaration

    Swift

    public func createFileTransferMessage(initialContent: Content) throws -> ChatMessage

    Parameters

    initialContent

    Content initial content.

    Return Value

    a new ChatMessage

  • Creates a forward message attached to the given chat room with a particular message.

    Declaration

    Swift

    public func createForwardMessage(message: ChatMessage) throws -> ChatMessage

    Parameters

    message

    ChatMessage message to be forwarded.

    Return Value

    a new ChatMessage

  • Creates a message attached to the given chat room with a plain text content filled with the given message.

    • deprecated: 01/07/2020. Use createMessageFromUtf8() instead.

    Declaration

    Swift

    @available(*, deprecated)
    public func createMessage(message: String?) throws -> ChatMessage

    Parameters

    message

    text message, nil if absent.

    Return Value

    a new ChatMessage

  • Creates a message attached to the given chat room with a plain text content filled with the given message. Introduced in 01/07/2020

    Declaration

    Swift

    public func createMessageFromUtf8(message: String?) throws -> ChatMessage

    Parameters

    message

    text message in UTF8, nil if absent.

    Return Value

    a new ChatMessage

  • Creates a reply message attached to the given chat room with a particular message.

    Declaration

    Swift

    public func createReplyMessage(message: ChatMessage) throws -> ChatMessage

    Parameters

    message

    ChatMessage message to reply to.

    Return Value

    a new ChatMessage

  • Creates a chat message with a voice recording attached to the given chat room.

    Warning

    If the recorder isn’t in Closed state, it will return an empty message!

    Declaration

    Swift

    public func createVoiceRecordingMessage(recorder: Recorder) throws -> ChatMessage

    Parameters

    recorder

    the Recorder object used to record the voice message.

    Return Value

    a new ChatMessage

  • Delete all messages from the history.

    Declaration

    Swift

    public func deleteHistory()
  • Delete a message from the chat room history.

    Declaration

    Swift

    public func deleteMessage(message: ChatMessage)

    Parameters

    message

    The ChatMessage object to remove.

  • Uses linphone spec to check if all participants support ephemeral messages. It doesn’t prevent to send ephemeral messages in the room but those who don’t support it won’t delete messages after lifetime has expired. - See also: ephemeralEnabled()

    Declaration

    Swift

    public func ephemeralSupportedByAllParticipants() -> Bool

    Return Value

    true if all participants in the chat room support ephemeral messages, false otherwise

  • Gets the chat message sent or received in this chat room that matches the message_id.

    Declaration

    Swift

    public func findMessage(messageId: String) -> ChatMessage?

    Parameters

    messageId

    The id of the message to find

    Return Value

    the ChatMessage if found or nil.

  • Find a participant of a chat room from its address.

    Declaration

    Swift

    public func findParticipant(address: Address) -> Participant?

    Parameters

    address

    The Address to search in the list of participants of the chat room

    Return Value

    The participant if found, nil otherwise.

  • Gets nb_message most recent messages from chat_room chat room, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistory(nbMessage: Int) -> [ChatMessage]

    Parameters

    nbMessage

    Number of message to retrieve. 0 means everything.

    Return Value

    A list of chat messages.

  • Gets nb_events most recent events from chat_room chat room, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistoryEvents(nbEvents: Int) -> [EventLog]

    Parameters

    nbEvents

    Number of events to retrieve. 0 means everything.

    Return Value

    The list of the most recent events.

  • Gets nb_events most recent chat message events from chat_room chat room, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistoryMessageEvents(nbEvents: Int) -> [EventLog]

    Parameters

    nbEvents

    Number of events to retrieve. 0 means everything.

    Return Value

    A list

  • Gets the partial list of messages in the given range, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistoryRange(begin: Int, end: Int) -> [ChatMessage]

    Parameters

    begin

    The first message of the range to be retrieved. History most recent message has index 0.

    end

    The last message of the range to be retrieved. History oldest message has index of history size - 1 (use getHistorySize() to retrieve history size)

    Return Value

    A list of chat messages.

  • Gets the partial list of events in the given range, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistoryRangeEvents(begin: Int, end: Int) -> [EventLog]

    Parameters

    begin

    The first event of the range to be retrieved. History most recent event has index 0.

    end

    The last event of the range to be retrieved. History oldest event has index of history size - 1

    Return Value

    The list of the found events.

  • Gets the partial list of chat message events in the given range, sorted from oldest to most recent.

    Declaration

    Swift

    public func getHistoryRangeMessageEvents(begin: Int, end: Int) -> [EventLog]

    Parameters

    begin

    The first event of the range to be retrieved. History most recent event has index 0.

    end

    The last event of the range to be retrieved. History oldest event has index of history size - 1

    Return Value

    The list of chat message events.

  • Return whether or not the chat room has been left.

    • deprecated: 16/03/2022 use isReadOnly() instead.

    Declaration

    Swift

    @available(*, deprecated)
    public func hasBeenLeft() -> Bool

    Return Value

    true if the chat room has been left, false otherwise.

  • Check if a chat room has given capabilities.

    Declaration

    Swift

    public func hasCapability(mask: Int) -> Bool

    Parameters

    mask

    a LinphoneChatRoomCapabilitiesMask mask

    Return Value

    true if the mask matches, false otherwise

  • Leave a chat room.

    Declaration

    Swift

    public func leave()
  • Returns wether lime is available for given peer or not.

    Declaration

    Swift

    public func limeAvailable() -> Bool
  • Mark all messages of the conversation as read.

    Declaration

    Swift

    public func markAsRead()
  • Notify the chatroom that a participant device has just registered. This function is meaningful only for server implementation of chatroom, and shall not by used by client applications.

    Declaration

    Swift

    public func notifyParticipantDeviceRegistration(participantDevice: Address)

    Parameters

    participantDevice

    list of the participant devices to be used by the group chat room

  • Used to receive a chat message when using async mechanism with IM enchat_roomyption engine.

    Declaration

    Swift

    public func receiveChatMessage(message: ChatMessage)

    Parameters

    message

    ChatMessage object

  • Remove a participant of a chat room.

    Declaration

    Swift

    public func removeParticipant(participant: Participant)

    Parameters

    participant

    The participant to remove from the chat room

  • Remove several participants of a chat room at once.

    Declaration

    Swift

    public func removeParticipants(participants: [Participant])

    Parameters

    participants

    The participants to remove.

  • Change the admin status of a participant of a chat room (you need to be an admin yourself to do this).

    Declaration

    Swift

    public func setParticipantAdminStatus(participant: Participant, isAdmin: Bool)

    Parameters

    participant

    The Participant for which to change the admin status

    isAdmin

    A boolean value telling whether the participant should now be an admin or not

  • Set the list of participant devices in the form of SIP URIs with GRUUs for a given participant. This function is meaningful only for server implementation of chatroom, and shall not by used by client applications.

    Declaration

    Swift

    public func setParticipantDevices(participantAddress: Address, deviceIdentities: [ParticipantDeviceIdentity])

    Parameters

    participantAddress

    The participant address

    deviceIdentities

    List of the participant devices to be used by the group chat room