IMClient
public class IMClient
IM Client
-
Length range of the client ID.
Declaration
Swift
public static let lengthRangeOfClientID: ClosedRange<Int>
-
Reserved value of the tag.
Declaration
Swift
public static let reservedValueOfTag: String
-
Undocumented
Declaration
Swift
public typealias Identifier = String
-
The client identifier.
Declaration
Swift
public let ID: IMClient.Identifier
-
The client tag.
Declaration
Swift
public let tag: String?
-
The user.
Declaration
Swift
public private(set) var user: LCUser? { get }
-
The client options.
Declaration
Swift
public let options: Options
-
The application that the client belongs to.
Declaration
Swift
public let application: LCApplication
-
The client delegate.
Declaration
Swift
public weak var delegate: IMClientDelegate?
-
The signature delegate.
Declaration
Swift
public weak var signatureDelegate: IMSignatureDelegate?
-
The dispatch queue where the event about IM are called. Default is main.
Declaration
Swift
public let eventQueue: DispatchQueue
-
The session state of the client.
- opened: opened.
- resuming: resuming.
- paused: paused.
- closing: closing.
- closed: closed.
Declaration
Swift
public enum SessionState
-
The current session state of the client.
Declaration
Swift
public private(set) var sessionState: SessionState { get set }
-
Options that can modify behaviors of client.
See moreDeclaration
Swift
public struct Options : OptionSet
-
Initialization.
Throws
Error.Declaration
Swift
public init( application: LCApplication = LCApplication.default, ID: IMClient.Identifier, tag: String? = nil, options: Options = .default, delegate: IMClientDelegate? = nil, signatureDelegate: IMSignatureDelegate? = nil, eventQueue: DispatchQueue = .main) throws
Parameters
ID
The client identifier. Length should in range
lengthRangeOfClientID
.tag
The client tag.
reservedValueOfTag
should not be used.options
@see
IMClient.Options
.delegate
@see
IMClientDelegate
.eventQueue
@see property
eventQueue
, default is main.application
The application that the client belongs to.
-
Initialization.
Throws
Error.Declaration
Swift
public convenience init( user: LCUser, tag: String? = nil, options: Options = .default, delegate: IMClientDelegate? = nil, signatureDelegate: IMSignatureDelegate? = nil, eventQueue: DispatchQueue = .main) throws
Parameters
user
The user which is valid.
tag
The client tag.
reservedValueOfTag
should not be used.options
@see
IMClient.Options
.delegate
@see
IMClientDelegate
.eventQueue
@see property
eventQueue
, default is main.
-
Options that can modify behaviors of session open operation.
See moreDeclaration
Swift
public struct SessionOpenOptions : OptionSet
-
Open session.
Declaration
Swift
public func open( options: SessionOpenOptions = .default, completion: @escaping (LCBooleanResult) -> Void)
Parameters
options
@see
IMClient.SessionOpenOptions
, default is.default
, empty options equal to[.reconnect]
.completion
Result callback.
-
Close session.
Declaration
Swift
public func close(completion: @escaping (LCBooleanResult) -> Void)
Parameters
completion
Result callback.
-
Create a Normal Conversation. Default is a Normal Unique Conversation.
Declaration
Swift
public func createConversation( clientIDs: Set<String>, name: String? = nil, attributes: [String: Any]? = nil, isUnique: Bool = true, completion: @escaping (LCGenericResult<IMConversation>) -> Void) throws
Parameters
clientIDs
The set of client ID. it’s the members of the conversation which will be created. the initialized members always contains current client’s ID. if the created conversation is unique, and server has one unique conversation with the same members, that unique conversation will be returned.
name
The name of the conversation.
attributes
The attributes of the conversation.
isUnique
True means create or get a unique conversation, default is true.
completion
Result callback.
-
Create a Chat Room.
Declaration
Swift
public func createChatRoom( name: String? = nil, attributes: [String: Any]? = nil, completion: @escaping (LCGenericResult<IMChatRoom>) -> Void) throws
Parameters
name
The name of the chat room.
attributes
The attributes of the chat room.
completion
Result callback.
-
Create a Temporary Conversation. Temporary Conversation is unique in it’s Life Cycle.
Declaration
Swift
public func createTemporaryConversation( clientIDs: Set<String>, timeToLive: Int32, completion: @escaping (LCGenericResult<IMTemporaryConversation>) -> Void) throws
Parameters
clientIDs
The set of client ID. it’s the members of the conversation which will be created. the initialized members always contains this client’s ID.
timeToLive
The time interval for the life of the temporary conversation.
completion
Result callback.
-
Create a new conversation query.
Declaration
Swift
public var conversationQuery: IMConversationQuery { get }
-
Get conversation instance from memory cache.
Declaration
Swift
public func getCachedConversation(ID: String, completion: @escaping (LCGenericResult<IMConversation>) -> Void)
Parameters
ID
The ID of the conversation.
completion
callback.
-
Remove conversation instance from memory cache.
Declaration
Swift
public func removeCachedConversation( IDs: Set<String>? = nil, all: Bool? = nil, completion: @escaping (LCBooleanResult) -> Void)
Parameters
IDs
The set of the conversation ID.
all
If this parameter set to
true
, then will remove all conversation instance from memory cache.completion
callback.
-
Query online state of clients, the ID in the result set means online.
Declaration
Swift
public func queryOnlineClients(clientIDs: Set<String>, completion: @escaping (LCGenericResult<Set<String>>) -> Void) throws
Parameters
clientIDs
The set of ID to be queried, count of IDs should in range 1…20.
completion
callback.
-
Open database of the local storage.
Throws
If client not init withusingLocalStorage
, then throws error.Declaration
Swift
public func prepareLocalStorage(completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
completion
Result of callback
-
Query Order Option for stored conversations.
- updatedTimestamp: By updated timestamp.
- createdTimestamp: By created timestamp.
- lastMessageSentTimestamp: By last message sent timestamp.
Declaration
Swift
public enum StoredConversationOrder
-
Get stored conversations and load them to memory container.
Throws
If client not init withusingLocalStorage
, then throws error.Declaration
Swift
public func getAndLoadStoredConversations( order: IMClient.StoredConversationOrder = .lastMessageSentTimestamp(descending: true), completion: @escaping (LCGenericResult<[IMConversation]>) -> Void) throws
Parameters
order
completion
Result of callback.
-
Delete the stored conversations and the messages belong to them.
Throws
If client not init withusingLocalStorage
, then throws error.Declaration
Swift
public func deleteStoredConversationAndMessages( IDs: Set<String>, completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
IDs
The ID set of the conversations that will be deleted.
completion
Result of callback.
-
Undocumented
Declaration
Swift
func newSessionCommand( op: IMOpType = .open, token: String? = nil, signature: IMSignature? = nil, isReopen: Bool? = nil) -> IMGenericCommand