Esempio n. 1
0
 // -----------------------------------------------------------
 // receive a terminateResponse message
 public static void terminateResponse(Socket s) throws GenericException {
   Message m = Message.receive(s);
   MessageType t = m.getMessageType();
   if (t == MessageType.TERM_RSP) return;
   else if (t == MessageType.TERM_ERR) throw new GenericException(t.getDescription());
   else if (t.isErrorType())
     throw new GenericException("Server encountered an " + t.getDescription());
   else throw new GenericException("Server's response is of an unexpected type.");
 }
 public static MessageType getMessageType(String description) {
   if (null == description) return null;
   for (MessageType _enum : MessageType.values()) {
     if (description.equals(_enum.getDescription())) return _enum;
   }
   return null;
 }
Esempio n. 3
0
 // -----------------------------------------------------------
 // receive an initResponse message
 public static void initResponse(Socket s) throws GenericException {
   System.out.println("Receiving init");
   Message m = Message.receive(s);
   System.out.println("Init received");
   MessageType t = m.getMessageType();
   if (t == MessageType.INIT_RSP) return;
   else if (t.isErrorType())
     throw new GenericException("Server encountered an " + t.getDescription());
   else throw new GenericException("Server's response is of an unexpected type: " + t.name());
 }