Changeset 8 for protocol/src/main/java
- Timestamp:
- 09/30/19 15:37:05 (5 years ago)
- Location:
- protocol/src/main/java/geniusweb/protocol
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java
r4 r8 28 28 import geniusweb.protocol.session.SessionSettings; 29 29 import geniusweb.protocol.session.SessionState; 30 import geniusweb.references.Parameters; 30 31 import geniusweb.references.PartyWithProfile; 31 32 import geniusweb.references.ProfileRef; … … 101 102 setupParties(); 102 103 nextTurn(); 103 } catch ( ProtocolException | IOException | InterruptedExceptione) {104 } catch (Throwable e) { 104 105 handleError("Failed to start up session", null, e); 105 106 } … … 155 156 .getParticipants(); 156 157 List<Reference> parties = participants.stream() 157 .map(parti -> (parti.getParty())).collect(Collectors.toList()); 158 .map(parti -> (parti.getParty().getPartyRef())) 159 .collect(Collectors.toList()); 158 160 List<ConnectionWithParty> connections = null; 159 161 log.log(Level.INFO, "SAOP connect " + parties); … … 241 243 PartyId partyid = connection.getParty(); 242 244 ProfileRef profile = state.getPartyProfiles().get(partyid).getProfile(); 245 Parameters params = state.getPartyProfiles().get(partyid).getParty() 246 .getParameters(); 243 247 if (profile == null) { 244 248 throw new IllegalArgumentException( … … 246 250 } 247 251 connection.send(new Settings(connection.getParty(), profile, getRef(), 248 state.getProgress() ));252 state.getProgress(), params)); 249 253 } 250 254 … … 276 280 if (!state.isFinal(System.currentTimeMillis())) 277 281 nextTurn(); 278 } catch ( Exceptione) {282 } catch (Throwable e) { 279 283 handleError("failed to handle action " + action, 280 284 partyconn.getParty().getName(), e); … … 305 309 */ 306 310 private synchronized void handleError(final String message, 307 final String party, final Exceptione) {311 final String party, final Throwable e) { 308 312 if (e instanceof ProtocolException) { 309 313 setState(state.with((ProtocolException) e)); -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettings.java
r1 r8 11 11 import geniusweb.protocol.tournament.TournamentSettings; 12 12 import geniusweb.references.PartyRef; 13 import geniusweb.references.PartyWithParameters; 13 14 import geniusweb.references.PartyWithProfile; 14 15 import geniusweb.references.ProfileRef; … … 35 36 */ 36 37 public class AllPermutationsSettings implements TournamentSettings { 37 private final List<Party Ref> parties;38 private final List<PartyWithParameters> parties; 38 39 private final List<ProfileRef> profiles; 39 40 private final boolean reuseParties; … … 58 59 @JsonCreator 59 60 public AllPermutationsSettings( 60 @JsonProperty("parties") List<Party Ref> parties,61 @JsonProperty("parties") List<PartyWithParameters> parties, 61 62 @JsonProperty("reuseParties") boolean reuseParties, 62 63 @JsonProperty("profiles") List<ProfileRef> profiles, … … 97 98 public ImmutableList<SessionSettings> permutations() { 98 99 ImmutableList<ImmutableList<PartyWithProfile>> partylistlist; 99 ImmutableList<PartyRef> partieslist = new FixedList<PartyRef>(parties); 100 ImmutableList<PartyWithParameters> partieslist = new FixedList<PartyWithParameters>( 101 parties); 100 102 ImmutableList<ProfileRef> profileslist = new FixedList<ProfileRef>( 101 103 profiles); … … 184 186 */ 185 187 private ImmutableList<ImmutableList<PartyWithProfile>> getParticipants( 186 ImmutableList<PartyRef> parties, ImmutableList<ProfileRef> profiles, 187 int n, boolean drawPartyWithPutback) { 188 189 Permutations<PartyRef> partiesPermutations; 188 ImmutableList<PartyWithParameters> parties, 189 ImmutableList<ProfileRef> profiles, int n, 190 boolean drawPartyWithPutback) { 191 192 Permutations<PartyWithParameters> partiesPermutations; 190 193 if (drawPartyWithPutback) { 191 194 partiesPermutations = new PermutationsWithReturn<>(parties, n); … … 199 202 // each tuple contains sesion info: a list of partyref and a list of 200 203 // profileref's. 201 Tuples<ImmutableList<Party Ref>, ImmutableList<ProfileRef>> tuples = new Tuples<>(204 Tuples<ImmutableList<PartyWithParameters>, ImmutableList<ProfileRef>> tuples = new Tuples<>( 202 205 partiesPermutations, profilesPermutations); 203 206 204 return new MapList<Tuple<ImmutableList<Party Ref>, ImmutableList<ProfileRef>>, ImmutableList<PartyWithProfile>>(207 return new MapList<Tuple<ImmutableList<PartyWithParameters>, ImmutableList<ProfileRef>>, ImmutableList<PartyWithProfile>>( 205 208 tuple -> partyprofilelist(tuple), tuples); 206 209 } … … 214 217 */ 215 218 private ImmutableList<PartyWithProfile> partyprofilelist( 216 Tuple<ImmutableList<Party Ref>, ImmutableList<ProfileRef>> tuple) {217 Function2<Party Ref, ProfileRef, PartyWithProfile> //218 makeparty = new Function2<Party Ref, ProfileRef, PartyWithProfile>() {219 Tuple<ImmutableList<PartyWithParameters>, ImmutableList<ProfileRef>> tuple) { 220 Function2<PartyWithParameters, ProfileRef, PartyWithProfile> // 221 makeparty = new Function2<PartyWithParameters, ProfileRef, PartyWithProfile>() { 219 222 @Override 220 public PartyWithProfile apply(PartyRef party, ProfileRef profile) { 223 public PartyWithProfile apply(PartyWithParameters party, 224 ProfileRef profile) { 221 225 return new PartyWithProfile(party, profile); 222 226 } 223 227 }; 224 return new MapThreadList<PartyWithProfile, Party Ref, ProfileRef>(228 return new MapThreadList<PartyWithProfile, PartyWithParameters, ProfileRef>( 225 229 makeparty, tuple.get1(), tuple.get2()); 226 230 }
Note:
See TracChangeset
for help on using the changeset viewer.