Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

re: code works until add this function to idl: string getClient1Name();  RSS feed

 
sid alam
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a counter object that has at most two clients connected to it.
I do not want the same two clients in the regClients String[]. Since restriction is that we only want two registered clients we can just check position one of array.
Note array starts from position 0.
When I add function getClient1Name(), results in error
All other code works.

Please help
[ ]
Sid
 
sid alam
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please one of the CORBA Geru's reply to this very simple problem. I want to check if a client is already registered with a counter. Constraint only two customers allowed.
[CODE]
{
interface Cback
{ void callback(in long par);
};
interface Counter
{ void regist(in Cback objRef, in string client);
void finish(in string client);
void action(in long num);
long getClientNo();
string getClient1Name(); //problem occurs when I add this function
};

here is my servant class in the server class

class CounterServant extends _CounterImplBase
{ private int actclient;
private Cback [] clients;
private String[] regclients;
private int number;
// constructor
CounterServant()
{ number = 0;
actclient = 0;
clients = new Cback[2];
regclients= new String[2];
System.out.println("SERVER SIDE");
System.out.println("counter servant started");
}
...
///return the current number of clients
public int getClientNo()
{
return actclient;
}
public String getClient1Name() {
String returnString = ""; //null string
if (regclients[0] !=null)
returnString = regclients[0];
return returnString;
}
...
}
here is the client class where a check is made to see if a client is registered to a specific counter.
class CbackServant extends _CbackImplBase
{ public void callback(int num)
{ System.out.println("CLIENT SIDE");
System.out.println("counter's current value = " + num);
}
}

public class CbackcomClient
{
public static void main(String args[])
{ try
{ // create and initialize the ORB
//note client is read from command prompt
//it is read at execution time
String client = new String(args[2]);
...
// get the root naming context
...
// resolve the Object Reference in Naming
...
Counter countRef = CounterHelper.narrow(ncRef.resolve(path));

CbackServant cbackRef = new CbackServant();

int clientNO = countRef.getClientNo();
if (clientNO <= 1)
{
System.out.println("current client number is: " + clientNO );

System.out.println("check if already a registered client");
/********* problem occurs here please help ******/
String client1 = ""; //null value string
if(clientNO == 1)
client1 = countRef.getClient1Name();
if (client.equals(client1) )
System.out.println("sorry your already a registered client");
orb.connect(cbackRef);
countRef.regist(cbackRef, client);
...
}
catch (Exception e)
{ System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}
A cry for help!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!