Central Server - Local Demon interface implementation

In order to send messages from Central Server to Local Demon and vice-versa, the appropriate interface was developed. It consists of set of classes that represent messages described in Central Server - Local Demon protocol, and class Net which takes care of sending and receiving those messages. All those classes are contained in messages package.

Examples:

Receiving messages:

//new object of class Net is created,

Net n = new Net(socket);

LoginMessage loginm;

String username, password;

Message m;

//message is received

m = n.receive();

if (m.type() == Conts.LOGIN) 

else

//access to the parameters of the message

username = loginm.getUsername();

password = loginm.getPasswd();

Sending messages:

//new object of class Net is created,

Net n = new Net(socket);

String user = new String("john");

String passwd = new String("passwd");

//new message is created with parameters user and passwd

LoginMessage loginm = new LoginMessage(user, passwd);

n.send(loginm);


For further information refer to messages package.