mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
3d9796db77
For testing stale hangup/busy messages Extracted MessageSender promise API Moved call debug actions to their own page // FREEBIE
25 lines
732 B
Swift
25 lines
732 B
Swift
//
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import PromiseKit
|
|
|
|
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 { fulfill, reject in
|
|
self.send(message, success: fulfill, failure: 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
|
|
}
|
|
}
|