session-ios/SignalServiceKit/src/Util/MessageSender+Promise.swift
Matthew Chen a98c82645c Start work on typing indicators.
* Update proto schema to reflect typing indicators.
* Sketch out OWSTypingIndicatorMessage.
* Add "online" to the service message params.
* Sketch out logic to send typing indicator messages.
* Sketch out OWSTypingIndicators class.
2018-10-31 12:11:29 -04:00

26 lines
767 B
Swift

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
import PromiseKit
import SignalServiceKit
public extension MessageSender {
/**
* Wrap message sending in a Promise for easier callback chaining.
*/
public func sendPromise(message: TSOutgoingMessage) -> Promise<Void> {
let promise: Promise<Void> = Promise { resolver in
self.send(message, success: resolver.fulfill, failure: resolver.reject)
}
// Ensure sends complete before they're GC'd.
// This *should* be redundant, since we should be calling retainUntilComplete
// at all call sites where the promise isn't otherwise retained.
promise.retainUntilComplete()
return promise
}
}