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
portNumberThe 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
serverThe 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
serverThe 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
serverthe server that had an error.
errorthe 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
serverThe server whose webSocket opened.
webSocketthe 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
serverthe server with the webSocket that received the message.
webSocketthe webSocket that received the message.
messagethe 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
serverThe server with the webSocket that closed.
webSocketthe webSocket that closed.
codeInt representing the code that the server released when the webSocket closed.
reasonString of the reason that the server’s webSocket closed.
wasCleanBool 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
serverthe server with the webSocket that failed.
webSocketthe webSocket that failed.
errorError, the reason for failing.
Return Value
None.
WebsocketServer Class Reference