WebsocketServer

public class WebsocketServer: NSObject, PSWebSocketServerDelegate

This is the class that connects the device running the Attest framework to the Attest Mobile UI Client.

  • Starts the WebSocketServer and attempts to connect using the portNumber given.

    Declaration

    Swift

    public static func start(_ portNumber: UInt)

    Parameters

    portNumber

    The portNumber that should be used to connect the framework to the Attest UI Client. If a simulator is used, the portNumber should be 48484.

    Return Value

    None.

  • Stops the WebSocketServer, disconnecting the framework from the Attest UI Client.

    Declaration

    Swift

    public static func stop()

    Return Value

    None.

  • Will print Server did stop to NSLog for the server specified. Delegate Method.

    Declaration

    Swift

    public func serverDidStop(_ server: PSWebSocketServer!)

    Parameters

    server

    The server that stopped.

    Return Value

    None.

  • Will print Server did start to NSLog for the server specified. Delegate Method.

    Declaration

    Swift

    public func serverDidStart(_ server: PSWebSocketServer!)

    Parameters

    server

    The server that started.

    Return Value

    None.

  • Will print to NSLog that the server failed with the error specified. Delegate Method.

    Declaration

    Swift

    public func server(_ server: PSWebSocketServer!, didFailWithError error: Error!)

    Parameters

    server

    the server that had an error.

    error

    the error that occurred.

    Return Value

    None.

  • Will print to NSLog that the server’s webSocket opened. Delegate Method.

    Declaration

    Swift

    public func server(_ server: PSWebSocketServer!, webSocketDidOpen webSocket: PSWebSocket!)

    Parameters

    server

    The server whose webSocket opened.

    webSocket

    the webSocket that opened.

    Return Value

    None.

  • Retrieves data and sends it through the webSocket to be used by the Attest UI Client. Delegate Method.

    Declaration

    Swift

    public func server(_ server: PSWebSocketServer!, webSocket: PSWebSocket!, didReceiveMessage message: Any!)

    Parameters

    server

    the server with the webSocket that received the message.

    webSocket

    the webSocket that received the message.

    message

    the actual message. The message is one of the following:

    • DEVICE - asking server to send information about the device.
    • ANALYZE - asking server to call Attest to run the accessibility analysis. Will print to NSLog with the results of the test.
    • HIGHLIGHT - asking server to highlight the view in violation.

    Return Value

    None.

  • Will print to NSLog when the webSocket on a server closes. Delegate Method.

    Declaration

    Swift

    public func server(_ server: PSWebSocketServer!, webSocket: PSWebSocket!, didCloseWithCode code: Int, reason: String!, wasClean: Bool)

    Parameters

    server

    The server with the webSocket that closed.

    webSocket

    the webSocket that closed.

    code

    Int representing the code that the server released when the webSocket closed.

    reason

    String of the reason that the server’s webSocket closed.

    wasClean

    Bool representing whether or not the webSocket was closed properly.

    Return Value

    None.

  • Will print to NSLog when the webSocket on a server fails. Delegate Method.

    Declaration

    Swift

    public func server(_ server: PSWebSocketServer!, webSocket: PSWebSocket!, didFailWithError error: Error!)

    Parameters

    server

    the server with the webSocket that failed.

    webSocket

    the webSocket that failed.

    error

    Error, the reason for failing.

    Return Value

    None.