What you need
Xcode is the IDE for OS X and iOS applications. Download Xcode.
2. Objective-C Lemma
Download the Objective-C Lemma and example project.
3. Add Lemma Libraries to Project
NoamLemma directory into your Xcode project.
4. Install Socket Rocket & CocoaAsyncSocket
CocoaAsyncSocket provides easy-to-use and powerful asynchronous socket libraries for OS X and iOS.
You can also install these libraries using CocoaPods by adding to your Podfile:
platform :ios, '6.0' pod 'CocoaAsyncSocket', '~> 7.3.1' pod 'SocketRocket', '~> 0.3.1-beta2'
Using the Objective-C Lemma
Include the Lemma library in your project.
Initialize and Run Lemma
The Noam lemma is initialized as a global singleton that can be easily accessed from any class. The Lemma will notify the delegate of connection success & data receipt via the delegate methods. Follow these steps to create the Noam lemma and connect to the server:
IDNoamLemma *lemma = [IDNoamLemma sharedLemmaWithClientName:@"GuestName" serverName:@"Test Room" hearsArray:@[ @"hearEventName1", @"hearEventName2" ] playsArray:@[@"speakEventName1", @"speakEventName2"] delegate:self]; [lemma connect];
Hearing messages use the following notifications.
// Data received from a plays broadcast. extern NSString * const IDNoamLemmaDidReceiveDataNotification; // id data from the event (NSString | NSArray | NSDictionary). extern NSString * const IDNoamLemmaDataKey; // Played event name (NSString). extern NSString * const IDNoamLemmaEventKey;
Other notifications related to hearing Noam messages are also supported.
// Connection error. extern NSString * const IDNoamLemmaConnectionFailedNotification; // Returns the NSError for the connection failure. extern NSString * const IDNoamLemmaErrorKey; // Connection closed. extern NSString * const IDNoamLemmaConnectionClosedNotification; // NSString connection closed reason. extern NSString * const IDNoamLemmaConnectionClosedReasonKey; // Lemma connected to Noam. extern NSString * const IDNoamLemmaDidConnectNotification; // The lemma that played the event (NSString). extern NSString * const IDNoamLemmaFromLemmaKey;
[[IDNoamLemma sharedLemma] sendData:@/*_JSON_SERIALIZABLE_DATA_*/ forEventName:@"speakEventName1"];
NSJSONSerialization is used to encode data, which requires:
- The top level object is an
- All objects are instances of
- All dictionary keys are instances of
- Numbers are not
See the example Xcode Project included in the download.
No known limitations or issues with this Lemma.
If you’re interested in checking out the source or contributing to this Lemma, visit our GitHub repository.