/*
@author  j.n.magee 20/11/96
*/
package concurrency.message;

import java.awt.*;
import java.util.*;
import java.applet.*;

/* ********************Entry**************************** */
// The definition of entry assumes that there can be many clients
// but only one server

class Entry extends Port {
  private CallMsg cm;

  public Object call(Object req) throws InterruptedException {
    Channel clientChan = new Channel();
    send(new CallMsg(req,clientChan));
    return clientChan.receive();
  }

  public Object accept() throws InterruptedException {
    cm = (CallMsg) receive();
    return cm.request;
  }

  public void reply(Object res) throws InterruptedException {
    cm.replychan.send(res);
  }

  private class CallMsg {
    Object  request;
    Channel replychan;
    CallMsg(Object m, Channel c)
      {request=m; replychan=c;}
  }

}