VertoWebSocket
public class VertoWebSocket : ZiwoWebSocket
extension VertoWebSocket: WebSocketDelegate
Subclass of ZiwoWebSocket
that uses websockets to help the communication between the protocol Verto
and iOS.
The class listen all the websocket messages and parses the methods sent by Verto
in order to notify the app.
Through this class, the user is able to call an agent, receive a call from outside, mute his microphone, switch the audio source, put the call on hold.
-
Protocol that handle both websocket connection state and
Verto
callbacks during its initialization and during a lifetime of a call.Declaration
Swift
private var delegate: VertoWebSocketDelegate?
-
ID of the Verto session defined after a login request (
func sendLoginRequest()
)Declaration
Swift
var sessId: String
-
Class initializer that create the websocket and connect the delegate.
Declaration
Swift
init(url: URL, delegate: VertoWebSocketDelegate)
Parameters
url
URL of the websocket
delegate
Delegate to connects
-
Connects the Verto websocket.
Declaration
Swift
func connect()
-
Disconnects the Verto websocket.
Declaration
Swift
func disconnect()
-
This methods parses the messages received by the Verto websocket. It converts a string into a dictionnary in order to handle the different
Verto
methods.Declaration
Swift
func parseMessage(_ message: String)
Parameters
message
The message received via the Verto websocket to parse and handle
-
Given a dictionnary received by the websocket, extract the ID of the Verto session and store it in
sessId
.Declaration
Swift
func parseSocketMessage(_ result: [String : String])
Parameters
result
Dictionnary that contains the ID of the Verto session.
-
Format a Verto event from a message that have been parsed (by
func parseMessage(_ message: String)
) to handle the behavior and call the correct delegate.Declaration
Swift
func parseVertoEvent(_ method: String, _ id: Int, _ params: [String : Any])
Parameters
method
String raw value of
VertoEvent
enum.id
ID of the Verto message.
params
Parameters returned by the Verto protocol.
-
Sends a JSON RPC to Verto protocol to authenticate the agent. If the request if correct and successfully sent. The protocol will send a
verto.clientReady
.Declaration
Swift
func sendLoginRequest()
-
Sends a JSON RPC to Verto protocol to initiate (the key
method
will have the valueinvite
) or answer a call (method
will have the valueanswer
).Declaration
Swift
func sendCallCreation(callRPC: String)
Parameters
callRPC
JSON RPC generated (by
VertoHelpers.createCallRPC(method: String, agentEmail: String, sdp: String, sessId: String, callID: String
)) that will be sent to Verto protocol -
Sends a JSON RPC to Verto protocol to initiate (the key
method
will have the valueinvite
) or answer a call (method
will have the valueanswer
) by sending back the RPC.Declaration
Swift
func sendCallAnswer(_ id: Int, _ params: [String : String])
Parameters
callRPC
JSON RPC generated (by
VertoHelpers.createCallRPC(method: String, agentEmail: String, sdp: String, sessId: String, callID: String
)) that will be sent to Verto protocol -
Sends a JSON RPC to Verto protocol to terminate the call.
Declaration
Swift
func hangup(callID: String)
Parameters
callID
The ID of the call you want to hangup.
-
Sends a JSON RPC to Verto protocol to indicate that the agent is callable.
Declaration
Swift
func sendBackInvite(_ id: Int, _ params: [String : String])
Parameters
id
The ID of the previous
verto.invite
Verto request.params
Dictionnary that contains incoming calls informations.
-
Sends a JSON RPC to Verto protocol to indicate that everything is set and the call is ready to be displayed.
Declaration
Swift
func sendBackDisplay(_ id: Int)
Parameters
id
The ID of the previous
verto.invite
Verto request. -
Sends a JSON RPC to Verto protocol to hold or unhold a call.
Declaration
Swift
func sendHoldAction(callID: String, _ isOn: Bool)
Parameters
callID
ID of the call.
isOn
Boolean that indicate whether the call has to be held or unheld.
-
Sends a JSON RPC to Verto protocol to send a digit to a call.
Declaration
Swift
func sendDigit(callID: String, number: String)
Parameters
callID
ID of the call.
number
The digit that will be sent to the call.
-
Sends a JSON RPC to Verto protocol to indicate that the call has to be transfer to a designed number. This is a non-attendance transfer.
Declaration
Swift
func blindTransfer(callID: String, number: String)
Parameters
callID
ID of the call.
number
Number to which the call will be redirected.
-
Delegate that will trigger
VertoWebSocket
delegates (websocket state, received messages from Verto protocol).Declaration
Swift
public func didReceive(event: WebSocketEvent, client: WebSocket)