Ejemplo n.º 1
0
 @Override
 public Mensaje obtenerMensaje(int mascara, boolean espera) {
   Mensaje msg = new MensajeSistema();
   msg.setOrigen(this.getId());
   msg.setDestino(this.getId());
   if (espera) msg.setTipo(msg.READ_MESSAGE_WAIT);
   else msg.setTipo(msg.READ_MESSAGE_NO_WAIT);
   msg.setMascara(mascara);
   this.establecer();
   this.send(null, msg);
   msg = this.receive(null);
   this.desconectar();
   return msg;
 }
Ejemplo n.º 2
0
  /**
   * Constructor of the class Connection
   *
   * @param esServidor indicates if is a server
   */
  public Conexion(boolean esServidor) {

    // Set connection
    if (!this.establecer()) {
      // TODO Check wrong connection
    }
    Mensaje msg = new MensajeSistema();

    // Configure the message connection

    msg.setTipo(msg.CREATE_CONNECTION);
    // FIXME esto no se sabe muy bien
    // It's not neccesary set connection because there is id
    // datos.setOrigen("");

    // Send the message connection

    this.send(null, msg);
    // Recive the answer
    msg = this.receive(null);
    // TODO tratamiento de errores del sistema
    if (msg.getTipo() == msg.OK) {
      // TODO mensaje de configuracion�?
      this.id = ((MensajeString) msg).getContenido();
    } else {
      // TODO tratamiento de errores
    }

    // Disconnect
    this.desconectar();
    // TODO: Establecer conexion con tu Demonio*/
  }