Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void run() {
- System.out.println("IpController Started");
- while (true) {
- proccessLogFile = proccessLine();
- if (proccessLogFile) {
- ipacc = InfoDB.ListarIpUserId(Integer.valueOf(this.prop.getProperty("userid")));
- if (null == ipacc) {
- ipacc = new IpAccountModel();
- }
- ipacc.setUserid(Integer.valueOf(this.prop.getProperty("userid")));
- ipacc.setAccount(Integer.valueOf(this.prop.getProperty("userid")));
- ipacc.setIp(this.prop.getProperty("peer"));
- InfoDB.salvarOuAtualizar(ipacc);
- }
- }
- }
- private void startupController() {
- try {
- this.file_reader = new FileReader(this.settings.getPvp_logs());
- this.br = new BufferedReader(this.file_reader);
- // End of File
- while ((brline = br.readLine()) != null) {
- }
- Thread.sleep(1000L);
- } catch (FileNotFoundException ex) {
- ThreadException(ex);
- } catch (IOException ex) {
- ThreadException(ex);
- } catch (InterruptedException ex) {
- ThreadException(ex);
- }
- }
- private boolean proccessLine() {
- try {
- brline = br.readLine();
- } catch (IOException ex) {
- ThreadException(ex);
- }
- if (brline == null) {
- try {
- Thread.sleep(1000L);
- return false;
- } catch (InterruptedException ex) {
- ThreadException(ex);
- }
- } else {
- brline = brline.replaceAll(" ", "\n");
- brline = brline.replaceAll(":", "\n");
- if (brline.contains("login")) {
- try {
- prop.load(new StringReader(brline));
- } catch (IOException ex) {
- ThreadException(ex);
- }
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement