Partially implement receiving pipeline
This commit is contained in:
parent
2d618cc6e9
commit
40098ac180
|
@ -1,8 +1,22 @@
|
|||
import SessionUtilities
|
||||
|
||||
public enum ReceivingPipeline {
|
||||
|
||||
// 1. Decrypt
|
||||
// 2. Convert binary to proto
|
||||
// 3. Convert proto to message
|
||||
// 4. Handle message
|
||||
public static func parse(_ data: Data) -> Message? {
|
||||
// TODO: Decrypt
|
||||
let proto: SNProtoContent
|
||||
do {
|
||||
proto = try SNProtoContent.parseData(data)
|
||||
} catch {
|
||||
SNLog("Couldn't parse proto due to error: \(error).")
|
||||
return nil
|
||||
}
|
||||
if let readReceipt = ReadReceipt.fromProto(proto) { return readReceipt }
|
||||
if let sessionRequest = SessionRequest.fromProto(proto) { return sessionRequest }
|
||||
if let typingIndicator = TypingIndicator.fromProto(proto) { return typingIndicator }
|
||||
if let closedGroupUpdate = ClosedGroupUpdate.fromProto(proto) { return closedGroupUpdate }
|
||||
if let expirationTimerUpdate = ExpirationTimerUpdate.fromProto(proto) { return expirationTimerUpdate }
|
||||
if let visibleMessage = VisibleMessage.fromProto(proto) { return visibleMessage }
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
|
||||
internal extension FixedWidthInteger {
|
||||
|
||||
init?(fromBigEndianBytes bytes: [UInt8]) {
|
||||
|
|
Loading…
Reference in New Issue