XPSDKConnection
@objc
open class XPSDKConnection : NSObject, XPSDKRequestDelegate
Main Connection. This class encapsulates:
- connection state management
- commands sending to the server
- keep alive messages (LiveMessage commands). * The class uses XPSDKRequest to send commands to server. Most commands methods (if not all), such as getViews and requestStream return a connectionRequest object to the callee. This object can be used to cancel the request if needed via the cancelRequest method.
-
The main connection
Declaration
Swift
open static var sharedConnection: XPSDKConnection -
The connection’s list of delegates
Declaration
Swift
open let delegates: NSMutableSet -
Server features
Declaration
Swift
open internal(set) var features: NSDictionary? -
Connection url
Declaration
Swift
open var url: URL? -
Connection url endpoint
Declaration
Swift
open var urlEntPoint: String -
Flag that is set to YES when the connection is race connection
Declaration
Swift
open var isRaceConnection: Bool -
Certificate cookie
Declaration
Swift
open var certificateCookie: Data? -
flag - set to YES if authentication is complete
Declaration
Swift
open var authenticationComplete: Bool -
Connection state
Declaration
Swift
open var state: XPSDKConnectionState -
DHEncryption
Declaration
Swift
open var dhe: DHEncryption? -
Connection id
Declaration
Swift
open var id: String? -
Reachability
Declaration
Swift
open var reachability: Reachability? -
Server info
Declaration
Swift
open var serverInfo: XPSDKServerInfo? -
Old connection
Declaration
Swift
open var oldConnection: AnyObject? -
Race connections
Declaration
Swift
open let raceConnections: NSMutableSet
-
Declaration
Swift
open var server: AnyObject?
-
Setups url string for connection to server
Declaration
Swift
public func setupWithURLString(_ urlString: String)Parameters
urlStringthe url (in string format) for connection to server
-
Setups connection with server info (containing data for server host, port, flag to indicate secure connection)
Declaration
Swift
public func setupWithServerInfo(_ serInfo: XPSDKServerInfo)Parameters
serInfoobject of type XPSDKServerInfo, containing data for server host, port, flag to indicate secure connection
-
Setups credentials for server connection and flag to indicate whether credentials should be saved
Declaration
Swift
public func setupWithUsername(_ username: String, password: String, shouldSave: Bool)Parameters
usernamethe username
passwordthe password
shouldSaveflag to indicate whether credentials should be saved
-
Adds race connection
Declaration
Swift
public func addRaceConnection(_ raceConnection: XPSDKConnection?)Parameters
raceConnectionthe race connection to be added
-
Adds request
Declaration
Swift
public func addRequest(_ request: XPSDKRequest?)Parameters
requestthe request to be added
-
Adds connection delegate
Declaration
Swift
public func addDelegate(_ delegate: XPMobileSDKConnectionDelegate?)Parameters
delegatethe delegate to be added
-
Removes connection delegate
Declaration
Swift
public func removeDelegate(_ delegate: XPMobileSDKConnectionDelegate?)Parameters
delegatethe delegate to be added
-
Declaration
Swift
public func explicitSetOfConnectionState(_ state: NSNumber) -
Updates application’s network activity indicator, depending on whether there is an request in execution, or an open video connection
Declaration
Swift
public func updateNetworkIndicator() -
Declaration
Swift
public static func resetSharedConnection()
-
Declaration
Swift
public func sendCommand( name:String, parameters:[String:String]?, successHandler:SuccessResponse?, failureHandler: FailureBlock? )
-
connect: Connect to server
More details about the Connect command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func connect(successHandler: SuccessResponse?, failureHandler: FailureBlock?) -> XPSDKRequestParameters
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
disconnect: Disconnects from server
Declaration
Swift
public func disconnect(withSuccessHandler successHandler: SuccessResponse?, failureHandler: FailureBlock?) -> XPSDKRequestParameters
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
requestStream(forCameraID:size:method:signal:fps:compressionLevel:userInitiatedDownsampling:keyFramesOnly:resizeSupported:time:usesTranscoding:successHandler:failureHandler:)Request stream method
More details about the RequestStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func requestStream(forCameraID cameraID: XPSDKViewID, size: CGSize, method: XPSDKVideoConnectionMethod, signal: XPSDKVideoConnectionSignal, fps:Int, compressionLevel:Int, userInitiatedDownsampling:Bool, keyFramesOnly:Bool, resizeSupported: Bool, time: NSDate?, usesTranscoding: Bool, successHandler: @escaping (XPSDKResponse, XPSDKVideoConnection) -> Void, failureHandler: FailureBlock?)Parameters
cameraIDthe ID of camera for which the video stream is requested
sizeThe size of the video to be streamed
methodType of the method for retrieving video data (Push or Pull)
signalType of the requested signal (live, playback or upload)
fpsFrame rate of the requested video (frames per second)
userInitiatedDownsamplingFlag to indicate whether user has initiated downsampling
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Cancel request stream method
Declaration
Swift
public func cancelRequestStream(request: XPSDKRequest)Parameters
requestThe request that will be cancelled
-
closeVideoConnection: Close video connection
More details about the CloseVideoConnection command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func closeVideoConnection(videoConnection: XPSDKVideoConnection, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoConnectionThe video connection that will be closed
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
purgeVideoConnections: close and remove all video connections
Declaration
Swift
public func purgeVideoConnections()
-
Change stream with fps method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func changeStream(forVideoID videoID: String, fps: Int, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
fpsnew value for frames per second
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Change stream with size and source rectangle method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func changeStream(forVideoID videoID: String, size: CGSize, sourceRect: CGRect, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
sizeThe new size of the video (Width and Height in pixels)
sourceRectThe coordinates of the cropping rectangle (Top, Left, Right, Bottom)
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Declaration
Swift
public func changeStream(forVideoID videoID: String, size: CGSize, successHandler: SuccessResponse?, failureHandler: FailureBlock?) -
Declaration
Swift
public func changeStream(forVideoID videoID: String, sourceRect: CGRect, successHandler: SuccessResponse?, failureHandler: FailureBlock?) -
Change stream with playback speed method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func changeStream(forVideoID videoID: String, playSpeed: Float, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
playSpeedSpeed of the playback (floating point). Sign determines the direction.
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Get previous sequence of playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func previousSequence(forVideoID videoID: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Get next sequence of playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func nextSequence(forVideoID videoID: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Get previous frame of playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func previousFrame(forVideoID videoID: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Get next frame of playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func nextFrame(forVideoID videoID: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Seek to timestamp in playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func seekToTimestamp(forVideoID videoID: String, timestamp: NSNumber, seekType: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
timestampTimestamp
seekTypeseek type
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Seek to time in playback video method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func seekToTime(forVideoID videoID: String, time: NSDate, seekType: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
timetime (NSDate)
seekTypeseek type
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Move camera with ptzMotion method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func moveCamera(forVideoID videoID: String, ptzMotion: XPSDKPTZMotion, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
ptzMotionPTZ Motion (Up, Down, Left, Right, ZoomIn, ZoomOut, Home
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Move camera with ptz preset method
More details about the ChangeStream command could be found in the Mobile Server Protocol documentation.
Declaration
Swift
public func moveCamera(forVideoID videoID: String, ptzPreset: XPSDKCameraPTZPreset, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
videoIDID of the video connection (GUID)
ptzPresetPTZ Preset
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Request to start live or payback audio session
Declaration
Swift
public func requestAudio(forMicrophoneId micId: String, audioEncoding: String, signalType: String, methodType: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
micIdId of the microphone, which stream is requested (GUID)
audioEncodingShows the encoding of the output. Possible values: Pcm/Mp3.
signalTypeType of the requested signal. Possible values: Live/Playback
methodTypeType of the method for retrieving video data. Possible values: Push/Pull
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
Request to close audio stream.
Declaration
Swift
public func closeAudioStream(forAudioId audioId: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?)Parameters
audioIdThe audio stream that will be closed
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
requestAudioStreamIn(forItemId:audioEncoding:samplingRate:bitsPerSample:numberOfChannels:successHandler:failureHandler:)Request to start push audio session.
Declaration
Swift
public func requestAudioStreamIn(forItemId itemId: String, audioEncoding: String, samplingRate: String, bitsPerSample: String, numberOfChannels: String, successHandler: SuccessResponse?, failureHandler: FailureBlock?) -> XPSDKRequestParameters
itemIdId of the item (speaker), which stream is requested (GUID)
audioEncodingShows the encoding of the output. Possible values: Pcm/Mp3.
samplingRateThe audio sampling rate in Hz value
bitsPerSampleAudio bits per sample. Possible values: 8/16.
numberOfChannelsNumber of audio channels (mono or stereo). Possible Values: ½.
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
-
login: Login method
Declaration
Swift
public func login(withSuccessHandler successHandler: SuccessResponse?, failureHandler: FailureBlock?) -> XPSDKRequest?Parameters
successHandlerThe success block which returns XPSDKResponse
failureHandlerThe failure block which returns NSError
XPSDKConnection Class Reference