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 ConnectionUpgradeFactory instance doesn’t need to work with the ServerResponse unless it needs to add special headers to the response.

    Declaration

    Swift

    func upgrade(handler: IncomingSocketHandler, request: ServerRequest, response: ServerResponse) -> (IncomingSocketProcessor?, String?)

    Parameters

    handler

    The IncomingSocketHandler that is handling the connection being upgraded.

    request

    The ServerRequest object of the incoming “upgrade” request.

    response

    The ServerResponse object that will be used to send the response of the “upgrade” request.

    Return Value

    A tuple of the created IncomingSocketProcessor and a message to send as the body of the response to the upgrade request. The IncomingSocketProcessor should be nil if the upgrade request wasn’t successful. If the message is nil, the response will not contain a body.