I am trying to implement a corba program (client) to retrieve customer
information from the server. Since the server allow to login once and
perform your operations until the lifetime experies, i want the client to use already login connection to perform the retrieve function without
login in to the server for every request.
Suppose retrieve has three functions, logon(), perform() and logoff()
Pseudo code;
Quote:
1. User runs a client application
./retrieve <URI> <customerID>
2. if the client program has already login, donot login, go to 4
3. Client program login to the server program
4. client program invoke perform(customerID,secKey, BaseList) to retrieve customer information, server will return customer status
5. Client program submit customer information to the calling program, in
this case, stdio
6. Unless specified, do not logoff
7. exit
8. go to 1
|
Here is the code snippets;
Code:
static void login(Base::Customer_ptr e) {
CORBA::String_var username = (const char*) "mimi";
CORBA::String_var password = (const char*) "ahh!!";
CORBA::String_var seckey= (const char*) "";
Base::BaseList BaseLists;
BaseList.length(2);
BaseList[0].bName = CORBA::string_dup("CATEGORY");
BaseList[0].bValue = CORBA::string_dup("VIP");
BaseList[1].bName = CORBA::string_dup("GENDER");
BaseList[1].bValue = CORBA::string_dup("F");
//I JUST WANT TO PERFORM THIS FUNCTION IFF IT HASNT BEEN INVOKED BEFORE,
ELSE SKIP THIS METHOD
e->Login(username,password,seckey); //NEW seckey WILL BE RETURNED
Base::BaseResult result;
result= e-> Perform(customerID, secKey, BaseList);
cerr << "***********************************" <<endl
<< "**** TASK RESULT *****" <<endl
<< "**** \t"<< taskresult << " *****" <<endl
<< "***********************************" <<endl;
//PERFORM THIS FUCTION ONLY IF NECESSARY, MAY CHECK argc[] for specified
option
e-> logoff();
}
Since the first login will return a seckey which can be used for subsequent runs, i was thinking of storing the key to the file (with md5checksum), and see if the key file exist before continue. The question is how can i do that.
Thanks in advance