mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			27 lines
		
	
	
		
			759 B
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			27 lines
		
	
	
		
			759 B
		
	
	
	
		
			Swift
		
	
| //
 | |
| //  Copyright (c) 2017 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 { fulfill, reject in
 | |
|             self.enqueue(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
 | |
|     }
 | |
| }
 |