In XCode I created a new project entitled "ROSessionsClient". I opened the MainMenu.nib file (which appears to have been converted to a .xib file now) and created my UI. My original UI was pretty close to what you would see today if you get the RemObjects SDK, but they did clean it up a touch. Here's what it looks like right now:

Since I'm using VMWare Fusion for Windows Development on OS X I copied the RODL file from the .NET Sessions sample folder to a folder in OS X and ran the RemObjects rodl2objc tool. That tool takes the RODL file and creates the proxies files we need to talk to our RemObjects server. I saved the Sessions_Library_Intf.h and Sessions_Library_Inft.m files to the ROSessionsClient it created to my ROSessionsClient folder. From there I went into XCode, right-clicked on "Classes" and selected the "Add" and then "Existing Files.... Once they were included in my project I was ready to get started in Interface Builder and XCode.
In my ROSessionsClient.h header file I added the necessary NSButton, NSTextField IBOutlets that were needed and wired them up in Interface Builder. I won't go into the details of how to do that since it's outside the scope of this article. We only needed a few methods since this is a pretty simple program. Once I was done the ROSessionsClient.h header file looked pretty close to the code below, the only real changes being the addition of BOOL loggedIn:
#import <Cocoa/Cocoa.h>
#import <RemObjectsSDK/RemObjectsSDK.h>
#import "Sessions_Library_Intf.h"
@interface ROSessionsClient : NSObject
{
IBOutlet NSTextField *edtServerURL;
IBOutlet NSTextField *lblSessionID;
IBOutlet NSTextField *lblClientID;
IBOutlet NSTextField *edtUsername;
IBOutlet NSTextField *edtPassword;
IBOutlet NSButton *btnLogin;
IBOutlet NSButton *btnLogout;
IBOutlet NSTextField *lblLoggedIn;
BOOL loggedIn;
IBOutlet NSTextField *edtName;
IBOutlet NSTextField *edtValue;
IBOutlet NSButton *btnGetValue;
IBOutlet NSButton *btnSetValue;
LoginService_Proxy *loginService;
SessionService_Proxy *sessionService;
ROBinMessage *message;
ROHTTPClientChannel *clientChannel;
NSString *myClientID;
NSString *mySessionID;
}
@end
The initialization code is really, really easy. You simply create your ROBinMessage and ROHttpClientChannel and then create the loginService and sessionService with them. The loginService and the sessionService are defined in the Sessions_Library_Intf files we created earlier using the rodl2objc tool. So our init method looks like this:
#pragma mark init/dealloc
- (id)init
{
self = [super init];
if (self)
{
InitializeSessions_Library();
message = [[ROBinMessage alloc] init];
[message setUseCompression:NO];
clientChannel = [[ROHTTPClientChannel alloc] init];
loginService = [[LoginService_Proxy alloc] initWithMessage:message channel:clientChannel];
sessionService = [[SessionService_Proxy alloc] initWithMessage:message channel:clientChannel];
//get the message clientID and turn it into a string we can display on the form.
myClientID = [[[message clientID] stringValue] retain];
NSLog(@"myClientID is %@", myClientID);
}
return self;
}
Naturally, the dealloc code is even simpler:
- (void)dealloc
{
[message release];
[clientChannel release];
[loginService release];
[sessionService release];
[myClientID release];
[super dealloc];
}
We've done quite a bit so far. Now that the basics are in place we can use the services we created to access some methods on the Sessions server. In Part 2 we're going to implement two of the server's methods, login and logout.
About The Author
Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC and his LinkedIn profile is here.
0 comments:
Post a Comment