34 lines
808 B
Swift
34 lines
808 B
Swift
|
//
|
||
|
// Message+Gemini.swift
|
||
|
// Gemini
|
||
|
//
|
||
|
// Created by Shadowfacts on 7/12/20.
|
||
|
//
|
||
|
|
||
|
import Network
|
||
|
|
||
|
private let requestKey = "gemini_request"
|
||
|
private let responseHeaderKey = "gemini_response_header"
|
||
|
|
||
|
extension NWProtocolFramer.Message {
|
||
|
|
||
|
convenience init(geminiRequest request: GeminiRequest) {
|
||
|
self.init(definition: GeminiProtocol.definition)
|
||
|
self[requestKey] = request
|
||
|
}
|
||
|
|
||
|
convenience init(geminiResponseHeader header: GeminiResponseHeader) {
|
||
|
self.init(definition: GeminiProtocol.definition)
|
||
|
self[responseHeaderKey] = header
|
||
|
}
|
||
|
|
||
|
var geminiRequest: GeminiRequest? {
|
||
|
self[requestKey] as? GeminiRequest
|
||
|
}
|
||
|
|
||
|
var geminiResponseHeader: GeminiResponseHeader? {
|
||
|
self[responseHeaderKey] as? GeminiResponseHeader
|
||
|
}
|
||
|
|
||
|
}
|