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 a special typeAlias for when we save a meeting as a new meeting. Making the meeting object editable adds a another modicum of security.
Declaration
Swift
typealias NewMeetingRefCon = (meetingObject: BMLTiOSLibEditableMeetingNode, refCon: AnyObject?) -
Undocumented
Declaration
Swift
typealias PermissionsTuple = (id: Int, name: String, permissions: BMLTiOSLibPermissions) -
This helps us to parse out the various Service bodies.
See moreDeclaration
Swift
class ServiceBodyRawDataDictionary
-
These are URL suffixes for calling into the semantic interface. We also use them as enumerations.
See moreDeclaration
Swift
enum BMLTiOSLibCommunicationHandlerSuffixes : String
-
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 semaphore that is set to let the class know that it needs to call a different callback for new and restored meetings.
Declaration
Swift
var _newMeetingCall: Bool -
This contains all the permissions in a simple string Dictionary.
Declaration
Swift
var _permissions: [BMLTiOSLibCommunicationHandler.PermissionsTuple] -
This contains all the various available Service bodies as a simple array of string dictionaries in a flat format.
Declaration
Swift
var _availableServiceBodies: [[String : String]] -
This is the communication manager that we are using to connect to the server.
Declaration
Swift
var _activeCommunicator: BMLTCommunicator! -
This contains all the various available formats.
Declaration
Swift
var _availableFormats: [[String : String]] -
This stores instances of our available formats. These are the
root
objects that are referenced everywhere else.Declaration
Swift
var _allformatsStored: [BMLTiOSLibFormatNode] -
This is a semaphore that is set while the
all used formats
call is going.Declaration
Swift
var _gettingAllUsedFormats: Bool -
This contains the available Server languages (not just the keys).
Declaration
Swift
var _availableServerLanguages: [BMLTiOSLibServerLang] -
This is the BMLTiOSLib instance that
owns
this connection.Declaration
Swift
weak var delegate: BMLTiOSLib! -
This contains the localization key for why the URL is wrong. It should be nil if everything is OK.
Declaration
Swift
var errorDescription: BMLTiOSLibCommunicationHandlerBadTestReasons! -
This contains all the various available Service bodies, as a flat array of
smart
nodes.Declaration
Swift
var allServiceBodies: [BMLTiOSLibHierarchicalServiceBodyNode] -
This contains all the various available Service bodies, but arranged in a hierarchy.
Declaration
Swift
var hierarchicalServiceBodies: BMLTiOSLibHierarchicalServiceBodyNode! -
These are the public formats.
Declaration
Swift
var formats: [BMLTiOSLibFormatNode] -
This is set to true if the admin login happened, and we are logged into an admin session.
Declaration
Swift
var adminLoggedIn: Bool -
This is the basic server info for our server.
Declaration
Swift
var serverInfo: BMLTiOSLibServerInfo?
-
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) orkm
(kilometers).Declaration
Swift
var distanceUnitsString: String { get } -
This is what our server distance units are. This will be either
mi
(miles) orkm
(kilometers).Declaration
Swift
var distanceUnits: BMLTiOSLibDistanceUnits { get }
-
Declaration
Swift
init(_ inDelegate: BMLTiOSLib) -
Belt and suspenders. Just make sure we remove everything.
Declaration
Swift
deinit
-
Belt and suspenders. Just make sure we remove everything.
Declaration
Swift
func clearStorage() -
This funtion deletes the node hierarchy passed in. It recurseively walks the hierarchy.
Declaration
Swift
func deleteNodes(_ inNode: BMLTiOSLibHierarchicalServiceBodyNode)Parameters
inNodeThis is the root node of the hierarchy we are to delete.
-
Declaration
Swift
func permissions(forServiceBody inServiceBody: BMLTiOSLibHierarchicalServiceBodyNode) -> BMLTiOSLibPermissionsReturn Value
If we are logged in as an admin, this will indicate the level of permission we have with a given Service body.
-
This cleans everything up if we have a problem.
Declaration
Swift
func cleanupOnAisleSeven() -
This recursive method is called after the formats query finishes, so it will not be established unless the entire connection has been validated.
Declaration
Swift
func populateHierarchicalServiceBodies(inParentObject: BMLTiOSLibHierarchicalServiceBodyNode?) -> BMLTiOSLibHierarchicalServiceBodyNodeParameters
inParentObjectThis is for recursion. If supplied (not-nil), then it is the parent node to be populated.
Return Value
a new node with a Service body. This node may have other nodes in it.
-
This handles communication errors.
Declaration
Swift
func handleCommunicationError(_ inOffendingCall: BMLTiOSLibCommunicationHandlerSuffixes, inBadData: AnyObject?)Parameters
inOffendingCallThis is the call that was being responded to.
inBadDataThis is the data that was not what it should have been.
-
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() -> BoolReturn 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
inMeetingObjectan editable meeting object.
-
This begins a meeting search.
Declaration
Swift
func meetingSearch(_ inURISuffix: String)Parameters
inURISuffixThis 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
inFromDateThis is a Date object that contains a date/time that represents the first meeting change instance. It can be nil for no Start Date.
inToDateThis is a Date object that contains a date/time that represents the last meeting change instance. It can be nil for no End Date.
inMeetingIDAn 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.
inServiceBodyIDAn 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.
inUserIDAn 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.
inMeetingNodeIf 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
inFromDateThis is a Date object that contains a date/time that represents the first meeting change instance. It can be nil for no Start Date.
inToDateThis is a Date object that contains a date/time that represents the last meeting change instance. It can be nil for no End Date.
inServiceBodyIDsAn 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) -> BoolParameters
inMeetingIDAn 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
inMeetingIDAn 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) -> BoolParameters
inMeetingIDAn Int, with the ID of the meeting to be rolled back.
inChangeIDAn 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) -> BoolParameters
inLoginIDThis is a string, with the login ID.
inPasswordThis 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() -> BoolReturn 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
meetingIDAn integer, with the BMLT ID for the meeting.
serviceBodyIDAn integer, with the BMLT ID for Service body for the meeting.
fromAddressThe email to be used as the
from
address. This is required, and should be valid.messageBodyA 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe parsed JSON object. This is an array of meeting objects and/or format objects, keyed by either
meetings
orformats
. -
Called when we want to parse the return from a login attempt.
Declaration
Swift
func handleLoginResponse(_ inResponseData: String)Parameters
inResponseDataThe parsed String response object.
-
Called when we want to parse the returned permission data.
Declaration
Swift
func handlePermissionResponse(_ inResponseData: AnyObject?)Parameters
inResponseDataThe 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
inResponseDatathe change object.
inMeetingNodeIf this is provided, then the changes will be sent directly to the meeting node, instead of the handler.
inDeletedMeetingsOnlyIf 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe JSON data object.
-
Called when we want to parse the return from a meeting deletion.
Declaration
Swift
func handleDeletedMeetingResponse(_ inResponseData: [String : AnyObject?])Parameters
inResponseDataThe 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
inResponseDataThe JSON data object.
-
Called when we want to parse the return from a get changes request.
Declaration
Swift
func handleNewMeetingResponse(_ inResponseData: [String : AnyObject?])Parameters
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe JSON data object. If nil, the call failed to produce. Check the handler’s error data member.
errorAny errors that occurred
refConThe 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
inResponseDataThe JSON data object. If nil, the call failed to produce. Check the handler’s error data member.
errorAny errors that occurred
refConThe 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
inResponseDataThe JSON data object. If nil, the call failed to produce. Check the handler’s error data member.
errorAny errors that occurred
refConThe 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
inResponseDataThe 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) -> StringParameters
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inResponseDataThe 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
inHandlerThe handler for this call.
inResponseDataThe JSON data object. If nil, the call failed to produce. Check the handler’s error data member.
inErrorAny errors that occurred
inRefConThe 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
inHandlerThe handler for this call.
parsedObjectThe partly-parsed response.
inResponseDataThe 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
inHandlerThe handler for this call.
parsedObjectThe partly-parsed response.
inResponseDataThe 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
inHandlerThe handler for this call.
parsedObjectThe partly-parsed response.
inResponseDataThe 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
inHandlerThe handler for this call.
parsedObjectThe partly-parsed response.
inResponseDataThe JSON data object. If nil, the call failed to produce. Check the handler’s error data member.
View on GitHub
BMLTiOSLibCommunicationHandler Class Reference