MCPcopy Create free account
hub / github.com/catabriga/graphwar / run

Method run

src/GlobalServer/LobbyPlayer.java:127–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers

nothing calls this directly

Calls 10

disconnectMethod · 0.95
checkStayAliveTimeMethod · 0.95
sendKeepAliveMethod · 0.95
checkTimeoutMethod · 0.95
readMessageMethod · 0.80
registerNewPlayerMethod · 0.80
sendListPlayersMethod · 0.80
sendListRoomsMethod · 0.80
removePlayerMethod · 0.45
handleMessageMethod · 0.45

Tested by

no test coverage detected