Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean connect = false;
- public static boolean click = false;
- public static boolean serverisworking = false;
- if(connect) {
- ip = ((TextField) scene.lookup("#iptextfield")).getText();
- System.out.println("Server connected to this"+ip+"IP");
- connect = false;
- }
- if(click) {
- client client = new client();
- try {
- client.run(((TextArea) scene.lookup("#messagetextarea")).getText());
- ((TextArea) scene.lookup("#outputtextarea")).setText("#messagetextarea");
- } catch(IOException ex) {
- Logger.getLogger(Lighproject.class.getName()).log(Level.SEVERE, null, ex);
- }
- click = false;
- }
- if (serverisworking && !Constants.text.equals("")){
- System.out.println("server is working");
- System.out.println(server.txt+"Catch error here ");
- ((TextArea) scene.lookup("#outputtextarea")).appendText(Constants.text);
- serverisworking = false;
- }
- }
- }, 0, 3000);
- }
- public void click() {
- click = true;
- }
- public void connect() {
- connect = true;
- serverisworking = true;
- }
- public static String txt="";
- public static void main(String[] args) throws IOException {
- ServerSocket ss = new ServerSocket(8000);
- while(true){
- Socket s =ss.accept();
- System.out.println("Client is connected");
- Lighproject.serverisworking=true;
- InputStreamReader in = new InputStreamReader (s.getInputStream());
- BufferedReader bf = new BufferedReader(in);
- String str = bf.readLine();
- System.out.println("Client"+str);
- Constants.text = str;
- PrintWriter pr = new PrintWriter(s.getOutputStream());
- pr.println("Hey there");
- pr.flush();
- }
- }
- public static String updateAndReturn(){
- return txt;
- }
- public static void run(String txt) throws IOException {
- Socket s = new Socket(Lighproject.ip,8000);
- PrintWriter pr = new PrintWriter (s.getOutputStream());
- pr.println(txt);
- pr.flush();
- InputStreamReader in = new InputStreamReader (s.getInputStream());
- BufferedReader bf = new BufferedReader (in);
- String str = bf.readLine();
- System.out.println("Server"+str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement