1
我試圖實現到C++庫SecureTransport的快速橋接。我'認爲'只要我知道如何在sslReadCallback/sslWriteCallback實現中讀取其中的內容,就可以傳入任何連接。這是我正在與之合作的假設。這似乎是這種情況時,我認爲SSLConnectionRef的定義:如何將我的swift類轉換爲UnsafePointer,如__bridge in objective-c
/* Opaque reference to an I/O connection (socket, endpoint, etc.) */
public typealias SSLConnectionRef = UnsafePointer<Void>
所以我只需要打開我的課變成UnsafePointer。不幸的是編譯器不喜歡我的嘗試。任何人都可以給我提示嗎?
func startSSLProcess()
{
self.sslContext = SSLCreateContext(kCFAllocatorDefault, SSLProtocolSide.ClientSide, SSLConnectionType.StreamType)
if let sslContext = self.sslContext
{
SSLSetIOFuncs(sslContext, sslReadCallback, sslWriteCallback)
SSLSetConnection(sslContext, UnsafePointer(self)) // <-- error
SSLSetSessionOption(sslContext, SSLSessionOption.BreakOnClientAuth, true)
SSLHandshake(sslContext)
}
}
在GCDAsyncSocket,它這樣做:
status = SSLSetConnection(sslContext, (__bridge SSLConnectionRef)self);
和
SubZeroGCDAsyncSocket *asyncSocket = (__bridge SubZeroGCDAsyncSocket *)connection;
..解開。這是什麼快速等值?
非常感謝!