Example #1
0
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    if (req.getParameter("sid") != null) {

      Session session;
      long sid;
      try {
        sid = Long.parseLong(req.getParameter("sid"));
      } catch (NumberFormatException e) {
        Send.Error(resp, "sid parse error");
        Log.sidInvalid(req);
        return;
      }
      try {
        session = new Session(sid, req);
      } catch (SecurityException e) {
        Send.Error(resp, e);
        Log.append(sid, e);
        return;
      }
      session.abandon();
    }
    Send.Data(
        resp,
        "{\"logout\":\""
            + UserServiceFactory.getUserService().createLogoutURL("close.html")
            + "\"}");
    return;
  }
Example #2
0
 public void start() {
   try {
     ServerSocket sSocket = new ServerSocket(12008);
     socket = sSocket.accept();
     Send s = new Send(socket);
     // Accept a = new Accept(socket);
     s.start();
     // a.start();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #3
0
 public History getSnapshot(int time) {
   // Create a snapshot of the receiver at the supplied time...
   History snapshot = new History();
   snapshot.startOfTime = time;
   snapshot.endOfTime = time;
   snapshot.behaviourChangedEvents = new Vector<BehaviourChanged>();
   snapshot.consumeEvents = new Vector<Consume>();
   snapshot.newActorEvents = new Vector<NewActor>();
   snapshot.sendEvents = new Vector<Send>();
   snapshot.stateEvents = new Hashtable<Integer, Hashtable<Key, Stack<State>>>();
   for (NewActor newActor : newActorEvents) {
     if (newActor.getTime() <= time) {
       BehaviourChanged b = null;
       for (BehaviourChanged b1 : behaviourChangedEvents) {
         if (b1.getId() == newActor.getId()
             && b1.getTime() <= time
             && b1.getTime() > newActor.getTime()
             && (b == null || b1.getTime() > b.getTime())) b = b1;
       }
       if (b == null)
         snapshot.newActorEvents.add(
             new NewActor(newActor.getId(), newActor.getBehaviour(), time));
       else snapshot.newActorEvents.add(new NewActor(newActor.getId(), b.getNewBehaviour(), time));
     }
   }
   for (Consume consume : consumeEvents) {
     if (consume.getTime() == time) snapshot.consumeEvents.add(consume);
   }
   for (Send send : sendEvents) {
     if (send.getTime() == time) snapshot.sendEvents.add(send);
   }
   for (int id : stateEvents.keySet()) {
     for (Key field : stateEvents.get(id).keySet()) {
       Stack<State> stack = stateEvents.get(id).get(field);
       if (!stack.isEmpty()) {
         State state = stack.peek();
         if (state.getTime() <= time)
           snapshot.state(id, field.getString(), state.getValue(), time);
       }
     }
   }
   return snapshot;
 }
Example #4
0
  public static void main(String[] args) throws IOException {
    try {
      int port = Integer.valueOf(args[1]);
      int numMsgs = Integer.valueOf(args[2]);
      boolean result = false;

      if ("send".equalsIgnoreCase(args[0])) {
        Send send = new Send("localhost", port, numMsgs);
        Reactor r = Proton.reactor(send);
        r.run();
        result = send.getResult();
      } else {
        Reactor r = Proton.reactor(new Recv(port, numMsgs));
        r.run();
        result = true;
      }
      System.exit(result ? 0 : 1);
    } catch (Throwable t) {
      t.printStackTrace();
      System.exit(1);
    }
  }
Example #5
0
 public void send_call_end() {
   IExceptionBlock exception_code = findNearestEnclosingTryExceptBlock();
   if (exception_code != null) {
     ((Send) currentCode).setInTryBlock(true);
   }
 }