BMLTiOSLibCommunicationHandler

class BMLTiOSLibCommunicationHandler : BMLTSession, BMLTCommunicatorDataSinkProtocol

This class is the workhorse of the system.

It is instantiated by the BMLTiOSLib class, and handles the actual communications with the Root Server.

  • This is the minimum server version we’ll support. Format is XYYYZZZ, with X = Main version (No leading zeroes), YYY = Feature Version (with leading zeroes), and ZZZ = Fix Version (with leading zeroes).

    Declaration

    Swift

    let s_minServerVersion: Int
  • This is a calculated property that returns a boolean to tell whether or not the server is valid and connected.

    Declaration

    Swift

    var isConnected: Bool { get }
  • This is a calculated property that returns a boolean to tell whether or not we are logged into an admin session.

    Declaration

    Swift

    var isLoggedInAsAdmin: Bool { get }
  • This returns our server-available formats.

    Declaration

    Swift

    var allAvailableFormats: [BMLTiOSLibFormatNode] { get }
  • This will hold the server version (as an integer).

    Declaration

    Swift

    var serverVersionAsInt: Int { get }
  • This contains the default location information for the server.

    Declaration

    Swift

    var defaultLocation: CLLocationCoordinate2D { get }
  • This is set to true if the server allows semantic administration.

    Declaration

    Swift

    var semanticAdminEnabled: Bool { get }
  • These are the available value keys for use when querying meeting data.

    Declaration

    Swift

    var availableMeetingValueKeys: [String] { get }
  • This is a list of the language keys for this server.

    Declaration

    Swift

    var availableLangKeys: [String] { get }
  • This is our default language key.

    Declaration

    Swift

    var defaulLangKey: String { get }
  • This is set to true if emails sent to the server are enabled (Goes to meeting contacts).

    Declaration

    Swift

    var emailMeetingContactsEnabled: Bool { get }
  • This is set to true if emails sent to the meeting contacts also send a copy to the Service body Admin for that meeting.

    Declaration

    Swift

    var emailServiceBodyAdminsEnabled: Bool { get }
  • This is number of changes stored per meeting.

    Declaration

    Swift

    var changeDepth: Int { get }
  • This is the server Google API Key

    Declaration

    Swift

    var googleAPIKey: String { get }
  • This is the version number as a string.

    Declaration

    Swift

    var versionString: String { get }
  • This is what our server distance units are. This will be either mi (miles) or km (kilometers).

    Declaration

    Swift

    var distanceUnitsString: String { get }
  • This is what our server distance units are. This will be either mi (miles) or km (kilometers).

    Declaration

    Swift

    var distanceUnits: BMLTiOSLibDistanceUnits { get }
  • Declaration

    Swift

    init(_ inDelegate: BMLTiOSLib)
  • Belt and suspenders. Just make sure we remove everything.

    Declaration

    Swift

    deinit
  • Called when we want to validate the server credentials.

    The server must be SSL, with a valid published CA value.

    Declaration

    Swift

    func testServerURI()
  • This is called to request the available Service bodies from the server.

    Declaration

    Swift

    func getServiceBodiesFromServer()
  • This is called to request the available formats from the server.

    Declaration

    Swift

    func getFormatsFromServer()
  • This is called to request the available languages (localizations) from the server.

    Declaration

    Swift

    func getLanguagesFromServer()
  • This is called to request the available permissions from the server.

    Declaration

    Swift

    func getPermissionsFromServer() -> Bool

    Return Value

    a Bool, which is true, if the connection is to a valid server with semantic admin on, and we are logged in.

  • This is called to set a meeting change.

    If the meeting ID is set to zero, then a new meeting is created.

    Declaration

    Swift

    func saveMeetingChanges(_ inMeetingObject: BMLTiOSLibEditableMeetingNode)

    Parameters

    inMeetingObject

    an editable meeting object.

  • This begins a meeting search.

    Declaration

    Swift

    func meetingSearch(_ inURISuffix: String)

    Parameters

    inURISuffix

    This is the suffix that is appened to the fundamental URI.

  • Called to get meeting change records from the Root Server.

    Declaration

    Swift

    func getAllMeetingChanges(inFromDate: Date?, inToDate: Date?, inServiceBodyID: Int?, inMeetingID: Int?, inUserID: Int?, inMeetingNode: BMLTiOSLibMeetingNode?)

    Parameters

    inFromDate

    This is a Date object that contains a date/time that represents the first meeting change instance. It can be nil for no Start Date.

    inToDate

    This is a Date object that contains a date/time that represents the last meeting change instance. It can be nil for no End Date.

    inMeetingID

    An Int, with the ID of one meeting for which we want to get changes. It can be nil for all meeting changes within the given date range.

    inServiceBodyID

    An Int, with the ID of one Service Body for which we want to get changes. It can be nil for all meeting changes within the given date range.

    inUserID

    An Int, with the ID of one Admin User for which we want to get changes. It can be nil for all meeting changes within the given date range. This is only valid for logged-in users.

    inMeetingNode

    If this is provided, then the changes will be sent directly to the meeting node, instead of the handler.

  • Called to get meeting change records from the Root Server.

    Declaration

    Swift

    func getDeletedMeetingChanges(inFromDate: Date?, inToDate: Date?, inServiceBodyIDs: [Int]?)

    Parameters

    inFromDate

    This is a Date object that contains a date/time that represents the first meeting change instance. It can be nil for no Start Date.

    inToDate

    This is a Date object that contains a date/time that represents the last meeting change instance. It can be nil for no End Date.

    inServiceBodyIDs

    An Array of Int, with the ID of one or more Service Bodies for which we want to get changes. It can be nil for all meeting changes within the given date range.

  • Called to restore a deleted meeting.

    We have to assume the logged-in admin has rights. If they don’t, it will be stopped at the server.

    Declaration

    Swift

    func restoreDeletedMeeting(_ inMeetingID: Int) -> Bool

    Parameters

    inMeetingID

    An Int, with the ID of the meeting to be restored.

    Return Value

    true, if the operation went successfully.

  • Called to delete a meeting.

    We have to assume the logged-in admin has rights. If they don’t, it will be stopped at the server.

    Declaration

    Swift

    func deleteMeeting(_ inMeetingID: Int)

    Parameters

    inMeetingID

    An Int, with the ID of the meeting to be deleted.

  • Called to rollback a meeting to before a change.

    We have to assume the logged-in admin has rights. If they don’t, it will be stopped at the server.

    Declaration

    Swift

    func rollbackMeeting(_ inMeetingID: Int, toBeforeChange inChangeID: Int) -> Bool

    Parameters

    inMeetingID

    An Int, with the ID of the meeting to be rolled back.

    inChangeID

    An Int, with the ID of the change.

    Return Value

    true, if the operation was dispatched successfully.

  • Called to log into a server that has semantic admin turned on.

    Declaration

    Swift

    func adminLogin(loginID inLoginID: String, password inPassword: String) -> Bool

    Parameters

    inLoginID

    This is a string, with the login ID.

    inPassword

    This is a string, with the password.

    Return Value

    a Bool, which is true, if the connection is to a valid server with semantic admin on.

  • Called to log out of a logged-in server that has semantic admin turned on.

    Declaration

    Swift

    func adminLogout() -> Bool

    Return Value

    a Bool, which is true, if the connection is to a valid server with semantic admin on.

  • If sending messages to meeting contacts is enabled, this function will send a basic email to the contact for this email.

    Declaration

    Swift

    func sendMessageToMeetingContact(meetingID: Int, serviceBodyID: Int, fromAddress: String, messageBody: String)

    Parameters

    meetingID

    An integer, with the BMLT ID for the meeting.

    serviceBodyID

    An integer, with the BMLT ID for Service body for the meeting.

    fromAddress

    The email to be used as the from address. This is required, and should be valid.

    messageBody

    A String containing the body of the message to be sent.

  • Called when we want to validate the server credentials.

    Declaration

    Swift

    func handleServerTest(_ inResponseData: BMLTiOSLibServerInfo)

    Parameters

    inResponseData

    The parsed JSON object. This is a server info object.

  • Called when we want to parse the returned Service body data.

    Declaration

    Swift

    func handleServiceBodies(_ inResponseData: [[String : String]])

    Parameters

    inResponseData

    The parsed JSON object. This is an array of simple Dictionaries of [String: String]

  • Called when we want to parse the returned format data.

    Declaration

    Swift

    func handleFormats(_ inResponseData: [String : [BMLTiOSLibFormatNode]])

    Parameters

    inResponseData

    The parsed JSON object. This is a Dictionary of an array of format objects, keyed by the formats key.

  • Called when we want to parse the returned language data.

    This method converts all the various data items (not that many) to Strings.

    Declaration

    Swift

    func handleLangs(_ inResponseData: [BMLTiOSLibServerLang])

    Parameters

    inResponseData

    The parsed JSON object. This is an array of Server language objects.

  • Called when we want to parse the returned data from a meeting search.

    Declaration

    Swift

    func handleMeetingSearchResponse(_ inResponseData: [String : AnyObject?])

    Parameters

    inResponseData

    The parsed JSON object. This is an array of meeting objects and/or format objects, keyed by either meetings or formats.

  • Called when we want to parse the return from a login attempt.

    Declaration

    Swift

    func handleLoginResponse(_ inResponseData: String)

    Parameters

    inResponseData

    The parsed String response object.

  • Called when we want to parse the returned permission data.

    Declaration

    Swift

    func handlePermissionResponse(_ inResponseData: AnyObject?)

    Parameters

    inResponseData

    The parsed JSON object. This is an array of Permissions tuples.

  • Called when we want to parse the return from a logout attempt.

    Declaration

    Swift

    func handleLogoutResponse()
  • Called when we want to parse the return from a meeting edit save attempt.

    Declaration

    Swift

    func handleMeetingEditSaveResponse(_ inResponseData: [String : AnyObject?])
  • Called when we want to parse the return from a get changes request.

    Declaration

    Swift

    func handleGetChangesResponse(_ inResponseData: [BMLTiOSLibChangeNode], inMeetingNode: BMLTiOSLibMeetingNode?, inDeletedMeetingsOnly: Bool)

    Parameters

    inResponseData

    the change object.

    inMeetingNode

    If this is provided, then the changes will be sent directly to the meeting node, instead of the handler.

    inDeletedMeetingsOnly

    If this is true, then only deleted meeting changes will be returned.

  • Called when we want to parse the return from a restore deleted meeting request.

    Declaration

    Swift

    func handleRestoreMeetingResponse(_ inResponseData: [String : AnyObject?])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a get meeting details request after a restore.

    Declaration

    Swift

    func handleRestoreMeetingInfoResponse(_ inResponseData: [String : [BMLTiOSLibEditableMeetingNode]])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a get meeting details request after a rollback.

    Declaration

    Swift

    func handleRollbackMeetingInfoResponse(_ inResponseData: [String : [BMLTiOSLibEditableMeetingNode]])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a meeting deletion.

    Declaration

    Swift

    func handleDeletedMeetingResponse(_ inResponseData: [String : AnyObject?])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a restore deleted meeting request.

    Declaration

    Swift

    func handleRollbackMeetingResponse(_ inResponseData: [String : AnyObject?])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a get changes request.

    Declaration

    Swift

    func handleNewMeetingResponse(_ inResponseData: [String : AnyObject?])

    Parameters

    inResponseData

    The JSON data object.

  • Called when we want to parse the return from a send message to contact operation.

    Declaration

    Swift

    func handleSentMessageResponse(_ inResponseData: AnyObject?)

    Parameters

    inResponseData

    The JSON data object.

  • This will parse the response data as JSON data, and create generic Dictionariy objects, Smart objects or Array objects.

    This is the heart of the data interpreter. It will create smart objects that will be used in subsequent operations. It will also correct for some inconsistencies in the data response from the server.

    Declaration

    Swift

    func parseJSONData(_ inResponseData: Any?, error inError: Error?, refCon inRefCon: Any?) -> AnyObject?

    Parameters

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

    error

    Any errors that occurred

    refCon

    The data/object passed in via the ‘refCon’ parameter in the initializer.

    Return Value

    An object, parsed from the data. This is returned as a generic AnyObject optional, but it will actually be an array or dictionary or smart object. It may be an Error object.

  • This parses an uncategorized JSON object. Parsing is recursive, so we dole out parsing to the main handlers.

    Declaration

    Swift

    func parseJSONOtherHandler(_ inResponseData: Any?, error inError: Error?, refCon inRefCon: Any?) -> AnyObject?

    Parameters

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

    error

    Any errors that occurred

    refCon

    The data/object passed in via the ‘refCon’ parameter in the initializer.

    Return Value

    An object, parsed from the data. This is returned as a generic AnyObject optional, but it will actually be an array or dictionary or smart object. It may be an Error object.

  • This parses a Dictionary JSON object. Parsing is recursive, so we dole out parsing to the main handlers.

    Declaration

    Swift

    func parseJSONDictionaryHandler(_ inResponseData: Any?, error inError: Error?, refCon inRefCon: Any?) -> AnyObject?

    Parameters

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

    error

    Any errors that occurred

    refCon

    The data/object passed in via the ‘refCon’ parameter in the initializer.

    Return Value

    An object, parsed from the data. This is returned as a generic AnyObject optional, but it will actually be an array or dictionary or smart object. It may be an Error object.

  • This parses a section of data that is an NSArray, and returns a new Swift Array (or single object in one instance).

    Declaration

    Swift

    func parseJSONArray(_ inResponseData: NSArray) -> AnyObject?

    Parameters

    inResponseData

    The JSON data object as an NSArray.

    Return Value

    an AnyObject optional that will usually be a Swift Array. However, it could be a single instance of BMLTiOSLibServerInfo.

  • This parses a number, and turns it into a String.

    Declaration

    Swift

    func parseJSONNumber(_ inResponseData: NSNumber) -> String

    Parameters

    inResponseData

    The JSON data object as an NSNumber.

    Return Value

    The number as a String.

  • This parses a Dictionary.

    In several cases, the Dictionary will represent a smart object, and this function will endeavor to return that object.

    It will call specialized parsers for these objects.

    Declaration

    Swift

    func parseJSONDictionary(_ inResponseData: NSDictionary) -> AnyObject?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This may be a smart object that represents the Dictionary.

  • This is a specialized parser for meeting/format search results.

    Declaration

    Swift

    func parseMeetingsAndFormatsJSONObject(inResponseData: NSDictionary) -> [String : [AnyObject?]]

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse.

  • This is a specialized parser for meeting search results without accompanying formats.

    Declaration

    Swift

    func parseMeetingsAloneJSONObject(inResponseData: NSDictionary) -> [String : [AnyObject?]]

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse.

  • This is a specialized parser for change responses.

    Declaration

    Swift

    func parseChangeJSONObject(inResponseData: NSDictionary) -> [String : [String : String]]

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse.

  • This is a specialized parser for format responses.

    Declaration

    Swift

    func parseFormatsJSONObject(inResponseData: NSDictionary) -> [String : [AnyObject?]]

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse.

  • This is a specialized parser for generic objects.

    Declaration

    Swift

    func parseGenericJSONObject(keys: [NSString], inResponseData: NSDictionary) -> [String : Any?]

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse.

  • This parses the JSON Dictionary into a Service body smart object.

    Declaration

    Swift

    func parseJSONServiceBody(_ inResponseData: NSDictionary) -> ServiceBodyRawDataDictionary?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • This parses the JSON Dictionary into a Server language smart object.

    Declaration

    Swift

    func parseJSONServerLang(_ inResponseData: NSDictionary) -> BMLTiOSLibServerLang?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • This parses the JSON Dictionary into a Server Info smart object.

    Declaration

    Swift

    func parseJSONServerInfo(_ inResponseData: NSDictionary) -> BMLTiOSLibServerInfo?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • This parses the JSON Dictionary into a Meeting Change smart object.

    Declaration

    Swift

    func parseJSONChangeObject(_ inResponseData: NSDictionary) -> BMLTiOSLibChangeNode?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • This parses the JSON Dictionary into a Meeting smart object.

    Declaration

    Swift

    func parseJSONMeeting(_ inResponseData: NSDictionary) -> BMLTiOSLibMeetingNode?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • This parses the JSON Dictionary into a format smart object.

    Declaration

    Swift

    func parseJSONFormat(_ inResponseData: NSDictionary) -> BMLTiOSLibFormatNode?

    Parameters

    inResponseData

    The JSON data object as an NSDictionary.

    Return Value

    The result of the parse. This will be a smart object that represents the Dictionary.

  • The response callback. This acts as a dispatcher, calling the appropriate handler.

    Declaration

    Swift

    func responseData(_ inHandler: BMLTCommunicator?, inResponseData: Any, inError: Error?, inRefCon: AnyObject?)

    Parameters

    inHandler

    The handler for this call.

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

    inError

    Any errors that occurred

    inRefCon

    The data/object passed in via the ‘refCon’ parameter in the initializer.

  • The response callback (second part to reduce CC). This acts as a dispatcher, calling the appropriate handler.

    Declaration

    Swift

    func handleCallType(_ callType: String, parsedObject: AnyObject?, inResponseData: Any)

    Parameters

    inHandler

    The handler for this call.

    parsedObject

    The partly-parsed response.

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

  • The response callback (third part to reduce CC). This acts as a dispatcher, calling the appropriate handler.

    Declaration

    Swift

    func handleCallTypePartDeux(_ callType: String, parsedObject: AnyObject?, inResponseData: Any)

    Parameters

    inHandler

    The handler for this call.

    parsedObject

    The partly-parsed response.

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

  • The response callback (fourth part to reduce CC). This acts as a dispatcher, calling the appropriate handler.

    Declaration

    Swift

    func handleCallTypePartTwee(_ callType: String, parsedObject: AnyObject?, inResponseData: Any)

    Parameters

    inHandler

    The handler for this call.

    parsedObject

    The partly-parsed response.

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.

  • The response callback (fifth part to reduce CC). This acts as a dispatcher, calling the appropriate handler.

    Declaration

    Swift

    func handleCallTypeLastPartISwear(_ callType: String, parsedObject: AnyObject?, inResponseData: Any)

    Parameters

    inHandler

    The handler for this call.

    parsedObject

    The partly-parsed response.

    inResponseData

    The JSON data object. If nil, the call failed to produce. Check the handler’s error data member.