Advertisement
TrodelHD

Untitled

May 9th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package connection;
  2.  
  3. import java.io.ObjectInputStream;
  4. import java.io.ObjectOutputStream;
  5.  
  6. import Rights.Right;
  7. import Var.var;
  8.  
  9. public class WaitingForMessage {
  10. ObjectInputStream OIS;
  11. ObjectOutputStream OOS;
  12. Right rights = var.NORIGHTS;
  13.  
  14. public WaitingForMessage(ObjectInputStream ois,ObjectOutputStream oos) {
  15. Thread thread = new Thread(){
  16.  
  17. public void run(){
  18. ObjectInputStream input = ois;
  19. ObjectOutputStream output = oos;
  20. Boolean aktive = true;
  21.  
  22. while(var.ServerIsAktive&&aktive){
  23. try {
  24. byte[][] message = (byte[][])input.readObject();
  25. new InputListener(message,output);
  26. } catch (Exception e) {
  27. if(e.getMessage().equals("Connection reset")){
  28. for(int i = 0;i<var.OutputStreams.size();i++){
  29. if(output.equals(var.OutputStreams.get(i))){
  30. var.OutputStreams.remove(i);
  31. }
  32. }
  33. aktive =false;
  34. this.interrupt();
  35. }
  36. }
  37. }
  38. }
  39. };
  40. thread.start();
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement