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) throwsParameters
IDThe client identifier. Length should in range
lengthRangeOfClientID.tagThe client tag.
reservedValueOfTagshould not be used.options@see
IMClient.Options.delegate@see
IMClientDelegate.eventQueue@see property
eventQueue, default is main.applicationThe 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) throwsParameters
userThe user which is valid.
tagThe client tag.
reservedValueOfTagshould 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].completionResult callback.
-
Close session.
Declaration
Swift
public func close(completion: @escaping (LCBooleanResult) -> Void)Parameters
completionResult 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) throwsParameters
clientIDsThe 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.
nameThe name of the conversation.
attributesThe attributes of the conversation.
isUniqueTrue means create or get a unique conversation, default is true.
completionResult callback.
-
Create a Chat Room.
Declaration
Swift
public func createChatRoom( name: String? = nil, attributes: [String: Any]? = nil, completion: @escaping (LCGenericResult<IMChatRoom>) -> Void) throwsParameters
nameThe name of the chat room.
attributesThe attributes of the chat room.
completionResult 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) throwsParameters
clientIDsThe set of client ID. it’s the members of the conversation which will be created. the initialized members always contains this client’s ID.
timeToLiveThe time interval for the life of the temporary conversation.
completionResult 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
IDThe ID of the conversation.
completioncallback.
-
Remove conversation instance from memory cache.
Declaration
Swift
public func removeCachedConversation( IDs: Set<String>? = nil, all: Bool? = nil, completion: @escaping (LCBooleanResult) -> Void)Parameters
IDsThe set of the conversation ID.
allIf this parameter set to
true, then will remove all conversation instance from memory cache.completioncallback.
-
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) throwsParameters
clientIDsThe set of ID to be queried, count of IDs should in range 1…20.
completioncallback.
-
Open database of the local storage.
Throws
If client not init withusingLocalStorage, then throws error.Declaration
Swift
public func prepareLocalStorage(completion: @escaping (LCBooleanResult) -> Void) throwsParameters
completionResult 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) throwsParameters
ordercompletionResult 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) throwsParameters
IDsThe ID set of the conversations that will be deleted.
completionResult of callback.
-
Undocumented
Declaration
Swift
func newSessionCommand( op: IMOpType = .open, token: String? = nil, signature: IMSignature? = nil, isReopen: Bool? = nil) -> IMGenericCommand
View on GitHub
Install in Dash
IMClient Class Reference