Within 1 java program I have 2 classes - MultiThread and Client
When I made the MultiThread class I checked off public static void main(String[] args)
The command "ask user1 ip1 user2 ip2" gets sent to the MultiThread class
When the user types accept which is defined in the Client class I need the Client part to return the word "accept" along with user1 and user2. The MultiThread class knows about them but Client does not.
Pretty much I need to somehow make a variable in Client that I can assign to user1 and user 2 from MultiThread
Does anyone have any ideas?
If you need more code then I will post it.
MultiThread
Client
When I made the MultiThread class I checked off public static void main(String[] args)
The command "ask user1 ip1 user2 ip2" gets sent to the MultiThread class
When the user types accept which is defined in the Client class I need the Client part to return the word "accept" along with user1 and user2. The MultiThread class knows about them but Client does not.
Pretty much I need to somehow make a variable in Client that I can assign to user1 and user 2 from MultiThread
Does anyone have any ideas?
If you need more code then I will post it.
MultiThread
Code:
else if (command.equals("ask")) {
System.out.println("ask command received");
String name1 = st.nextToken();
String ip1 = st.nextToken();
String name2 = st.nextToken();
String ip2 = st.nextToken();
System.out.println("name1=" + name1 + " " + "ip1=" + ip1 + " " + "name2=" + name2 + " " + "ip2=" + ip2);
System.out.println("Do you want to add " + name1 + "(accept/reject)");
}
Code:
else if ("accept".equals(input)) {
System.out.println("accept command received\n");
Socket Socket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
Socket = new Socket(server, port);
out = new PrintWriter(Socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(Socket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: " + server);
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: " + server);
System.exit(1);
}
out.println("accept");
out.close();
in.close();
Socket.close();
}