Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void whileChatting() throws IOException {
- sendMessage("&nume"+nume);
- do {
- try {
- Object object = input.readObject();
- if(object instanceof String)
- showMessage("n" + (String) object);
- //here is where i want to receive objects so that's why i used instanceof
- } catch (ClassNotFoundException var2) {
- showMessage("Unknown data received!");
- }
- } while(!message.equals("SERVER - END"));
- }
- @Override
- public void run() {
- String message = " ";
- try {
- Object object = new Object();
- while (true){
- object = reader.readObject();
- if(object instanceof String){
- message = (String) object;
- System.out.println(message);
- if(message.startsWith("&nume")) {
- nume = message.substring(5);
- sendToAll(nume + " connected");
- //playersState.addTo(nume , playersState.getLobbyPlayers()); <------------
- //here is the problem
- }
- else if(message.startsWith("/left")){
- sock.close();
- sendToAll(nume + " left");
- break;
- }
- else sendToAll(nume + " - " +message);
- }
- }
- } catch (Exception ex) {
- try {
- System.out.println("inchis");
- sock.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- System.exit(0);
- }
- }
- }
- public void addTo(String name, List<String> list){
- list.add(name);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement