WSConnectionUpgradeFactory

public class WSConnectionUpgradeFactory : ConnectionUpgradeFactory

The implementation of the ConnectionUpgradeFactory protocol for the WebSocket protocol. Participates in the HTTP protocol upgrade process when upgarding to the WebSocket protocol.

  • The name of the protocol supported by this ConnectionUpgradeFactory.

    Declaration

    Swift

    public let name: String
  • “Upgrade” a connection to the WebSocket protocol. Invoked by the KituraNet.ConnectionUpgrader when an upgrade request is being handled.

    Declaration

    Swift

    public 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 WSSocketProcessor and a message to send as the body of the response to the upgrade request. The WSSocketProcessor will be nil if the upgrade request wasn’t successful. If the message is nil, the response will not contain a body.