Package jnode.event

Examples of jnode.event.ConnectionEndEvent


    public void handle(IEvent event) {
        synchronized (ConnectionStat.class) {

            if (event instanceof ConnectionEndEvent) {
                ConnectionEndEvent evt = (ConnectionEndEvent) event;

                ConnectionStatData data = new ConnectionStatData(statPath);

                ConnectionStatData.ConnectionStatDataElement current;

                List<ConnectionStatData.ConnectionStatDataElement> elements = data.load();

                int pos = data.findPos(evt.getAddress(), elements);
                if (pos == -1) {
                    current = new ConnectionStatData.ConnectionStatDataElement();
                    current.linkStr = evt.getAddress() != null ? evt.getAddress().toString() : null;
                } else {
                    current = elements.get(pos);
                }

                if (evt.isIncoming()) {
                    if (evt.isSuccess()) {
                        current.incomingOk++;
                    } else {
                        current.incomingFailed++;
                    }
                } else {
                    if (evt.isSuccess()) {
                        current.outgoingOk++;
                    } else {
                        current.outgoingFailed++;
                    }
                }
                current.bytesReceived += evt.getBytesReceived();
                current.bytesSended += evt.getBytesSended();

                data.store(evt.getAddress(), current);
            }
        }
    }
View Full Code Here


        }
      }
    } catch (IOException e2) {
      logger.l2("Error while closing key", e2);
    }
    ConnectionEndEvent event = null;
    if (!foreignAddress.isEmpty()) {
      for (FtnAddress addr : foreignAddress) {
        PollQueue.getSelf().end(addr);
      }
      time /= 1000;
      long scps = (time > 0) ? total_sent_bytes / time : total_sent_bytes;
      long rcps = (time > 0) ? total_recv_bytes / time : total_recv_bytes;

      String address = (foreignLink != null) ? foreignLink
          .getLinkAddress() : foreignAddress.get(0).toString();
      logger.l2(String.format(
          "Done: %s %s, %s, S/R: %d/%d (%d/%d bytes) (%d/%d cps)",
          (clientConnection) ? "to" : "from", address,
          (connectionState == STATE_END) ? "OK" : "ERROR",
          total_sent_files, total_recv_files, total_sent_bytes,
          total_recv_bytes, scps, rcps));
      event = new ConnectionEndEvent(new FtnAddress(address),
          !clientConnection, (connectionState == STATE_END),
          total_recv_bytes, total_sent_bytes);
    } else {
      event = new ConnectionEndEvent(clientConnection, false);
      logger.l3("Connection ended as unknown");
    }
    Notifier.INSTANSE.notify(event);
  }
View Full Code Here

TOP

Related Classes of jnode.event.ConnectionEndEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.