()
| 125 | |
| 126 | |
| 127 | public void run() |
| 128 | { |
| 129 | running = true; |
| 130 | |
| 131 | try |
| 132 | { |
| 133 | this.name = connection.readMessage(); |
| 134 | |
| 135 | System.out.println("New name: "+name); |
| 136 | |
| 137 | if(name.compareTo(Constants.DUMMY_NAME) == 0) |
| 138 | { |
| 139 | this.dummy = true; |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | this.dummy = false; |
| 144 | } |
| 145 | } |
| 146 | catch (IOException e1) |
| 147 | { |
| 148 | e1.printStackTrace(); |
| 149 | |
| 150 | disconnect(); |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | this.globalServer.registerNewPlayer(this); |
| 155 | this.globalServer.sendListPlayers(this); |
| 156 | this.globalServer.sendListRooms(this); |
| 157 | |
| 158 | while(running) |
| 159 | { |
| 160 | try |
| 161 | { |
| 162 | String message = connection.readMessage(); |
| 163 | |
| 164 | if(message == null) |
| 165 | { |
| 166 | this.globalServer.removePlayer(this); |
| 167 | disconnect(); |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | this.globalServer.handleMessage(message, this); |
| 172 | |
| 173 | if(checkStayAliveTime()) |
| 174 | { |
| 175 | sendKeepAlive(); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | catch (SocketTimeoutException e) |
| 180 | { |
| 181 | if(checkTimeout()) |
| 182 | { |
| 183 | this.globalServer.removePlayer(this); |
| 184 | disconnect(); |
nothing calls this directly
no test coverage detected