ConnectionUpgradeFactory
public protocol ConnectionUpgradeFactory
A class to create new IncomingSocketProcessors for upgraded connections. These factory classes are invoked
when an “upgrade” HTTP request comes to the server for a particular protocol.
-
The name of the protocol supported by this
ConnectionUpgradeFactory. A case insensitive compare is made with this name.Declaration
Swift
var name: String { get } -
“Upgrade” a connection to the protocol supported by this
ConnectionUpgradeFactory.Note
The
ConnectionUpgradeFactoryinstance doesn’t need to work with theServerResponseunless it needs to add special headers to the response.Declaration
Swift
func upgrade(handler: IncomingSocketHandler, request: ServerRequest, response: ServerResponse) -> (IncomingSocketProcessor?, String?)Parameters
handlerThe
IncomingSocketHandlerthat is handling the connection being upgraded.requestThe
ServerRequestobject of the incoming “upgrade” request.responseThe
ServerResponseobject that will be used to send the response of the “upgrade” request.Return Value
A tuple of the created
IncomingSocketProcessorand a message to send as the body of the response to the upgrade request. TheIncomingSocketProcessorshould be nil if the upgrade request wasn’t successful. If the message is nil, the response will not contain a body.
View on GitHub
ConnectionUpgradeFactory Protocol Reference