- Timestamp:
- 01/28/20 10:20:01 (5 years ago)
- Location:
- src/main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/geniusweb/runserver/RunNego.java
r5 r8 60 60 response.sendError(HttpServletResponse.SC_BAD_REQUEST, 61 61 e.getMessage()); 62 System.err.println("Run request failed " + reqstring); 63 e.printStackTrace(); // helpful for debugging run requests 62 64 return; 63 65 } -
src/main/java/geniusweb/runserver/RunningNego.java
r5 r8 83 83 out.print(jackson.writeValueAsString(sessionState)); 84 84 out.close(); 85 } catch ( IOException e) {85 } catch (Throwable e) { // also catch outOfMem etc. 86 86 log.log(Level.SEVERE, "Failed to write log file for " + sessionid, 87 87 e); -
src/main/java/geniusweb/runserver/WebSocketProtToPartyConn.java
r7 r8 46 46 implements ProtocolToPartyConn { 47 47 private final static ObjectMapper jackson = new ObjectMapper(); 48 // 20MB seems reasonable limit? 49 private static final int MAX_MESSAGE_SIZE = 20 * 1024 * 1024; 48 50 private final Reporter log; 49 51 … … 178 180 public void onOpen(Session session) { 179 181 log.log(Level.INFO, "Party is being connected: " + session); 182 session.setMaxTextMessageBufferSize(MAX_MESSAGE_SIZE); 183 session.setMaxBinaryMessageBufferSize(MAX_MESSAGE_SIZE); 180 184 this.session = session; 181 185 } -
src/main/webapp/newsession.xhtml
r7 r8 13 13 14 14 <br /> Protocol: 15 <select> 16 <option value="SAOP">SAOP</option> 15 <select id="selectedprotocol" onchange="selectProtocol()"> 16 <option value="SAOP">SAOP (stacked alternating offers)</option> 17 <option value="SHAOP">SHAOP (stacked human alternating 18 offers)</option> 17 19 </select> 18 20 … … 21 23 max="10000" value="10" /> 22 24 <select id="deadlinetype"> 25 <option value="ROUNDS">rounds</option> 23 26 <option value="TIME">seconds</option> 24 <option value="ROUNDS">rounds</option>25 27 </select> 26 28 … … 43 45 value="localhost:8080/partiesserver-1.1.0" 44 46 pattern=".*:[0-9]+/partiesserver" size="30" 45 onchange="connectParties()"> </input> <br /> <br /> <b>Edit 46 next party</b> <br /> Party: <select id="partyselection"> 47 </select> <br /> Profile: <select id="profileselection"> 48 </select> <br /> Parameters: { <input type="text" id="parameters" 49 onchange="updateParameters()" value="" maxlength="100" /> } <br /> <br /> 47 onchange="connectParties()"> </input> <br /> <br /> <b>Party 48 settings</b> <br /> Party : <select id="partyselection"> 49 </select> <br /> Profile: <select id="profileselection"></select> Filter: <input 50 type="text" id="filter" value="" maxlength="40" /> <br /> 51 Parameters: { <input type="text" id="parameters" 52 onchange="updateParameters()" value="" maxlength="100" /> } <br /> 53 <br /> 54 55 <div id="cobsetting"> 56 <input type="checkbox" id="advancedCobSettings" onchange="advancedCobSet()" ></input> 57 Advanced COB settings<br/> 58 <div id="advancedsettings" style="display:none"> 59 <b>COB party settings</b> <br /> Party : <select 60 id="cobpartyselection"> 61 </select> <br /> Profile: <select id="cobprofileselection"></select> 62 Filter: <input type="text" id="cobfilter" value="" 63 maxlength="40" /> <br /> Parameters: { <input 64 type="text" id="cobparameters" onchange="updateCobParameters()" 65 value="" maxlength="100" /> } <br /> <br /> 66 </div> 67 </div> 50 68 51 69 <button onclick="addParty()">Add</button> … … 53 71 54 72 <br /> <br /> <b>Selected Profiles, Parties for the session</b> 55 <table> 73 <table id="selectedpartiestable" width="100%"> 74 <colgroup> 75 <col /> 76 <col /> 77 <col /> 78 <col /> 79 <col /> 80 <col /> 81 </colgroup> 56 82 <thead> 57 <th align="left" width='40%'>Party</th> 58 <th align="left" width='20%'>Parameters</th> 59 <th align="left" width='40%'>Profile</th> 83 <tr> 84 <th align="center">Party</th> 85 <th align="center">Parameters</th> 86 <th align="center">Profile</th> 87 88 <th align="center">COB Party</th> 89 <th align="center">COB Parameters</th> 90 <th align="center">COB Profile</th> 91 </tr> 60 92 </thead> 61 93 <tbody id="partiesList"> 62 <tr id="partiesList">63 </tr>64 65 94 </tbody> 66 95 </table> … … 84 113 85 114 <script type="application/javascript"> 115 116 117 86 118 87 119 … … 114 146 */ 115 147 var partyprofiles=[]; 148 149 var cobpartyprofiles=[]; 116 150 117 151 /** from http://fitzgeraldnick.com/2010/08/10/settimeout-patterns.html */ 118 152 153 function getAdvancedCobSettings() { 154 return document.getElementById('advancedCobSettings').checked; 155 } 156 157 function advancedCobSet() { 158 document.getElementById('advancedsettings').style.display=(getAdvancedCobSettings()?'':'none'); 159 } 160 119 161 function async (fn) { 120 162 setTimeout(fn, 1000); … … 131 173 } 132 174 133 175 /** 176 Called when user changes the protocol */ 177 function selectProtocol() { 178 var visible=getSelectedProtocol() == "SHAOP"; 179 180 document.getElementById("cobsetting").style.display=(visible ? 'block': 'none'); 181 var tbl = document.getElementById('selectedpartiestable'); 182 tbl.getElementsByTagName('col')[3].style.visibility=(visible?'':'collapse'); 183 tbl.getElementsByTagName('col')[4].style.visibility=(visible?'':'collapse'); 184 tbl.getElementsByTagName('col')[5].style.visibility=(visible?'':'collapse'); 185 186 } 134 187 135 188 /** … … 228 281 */ 229 282 function updateParties(parties) { 230 var combobox = document.getElementById("partyselection"); 283 updatePartiesCombobox(parties, document.getElementById("partyselection"),['SAOP','SHAOP']); 284 updatePartiesCombobox(parties, document.getElementById("cobpartyselection"),['COB']); 285 } 286 287 /** 288 @param parties a list of parties r(as received from the server) 289 @param combobox a combobox element to put the party URLs in 290 @param behaviours a list of behaviours for the parties. Only these are put in the combobox. 291 */ 292 function updatePartiesCombobox(parties, combobox, behaviours) { 231 293 combobox.options.length=0; 232 for (var party in parties) { 294 for (var p in parties) { 295 var party = parties[p]; 296 if (intersect(party.capabilities.behaviours, behaviours).length==0) 297 continue; 233 298 var option = document.createElement('option'); 234 option.text = option.value = part ies[party].uri;299 option.text = option.value = party.uri; 235 300 combobox.add(option, 0); 236 301 } 237 } 238 302 303 } 304 305 /** 306 @param a a list 307 @param b another list 308 @return intersection of a and b 309 */ 310 function intersect(a, b) { 311 var t; 312 if (b.length > a.length) t = b, b = a, a = t; // indexOf to loop over shorter 313 return a.filter(function (e) { 314 return b.indexOf(e) > -1; 315 }); 316 } 317 239 318 240 319 /** … … 262 341 var domain = domaincombobox.options[domaincombobox.selectedIndex].value; 263 342 264 var profilecombo = document.getElementById("profileselection"); 343 updateProfileComboBox(document.getElementById("profileselection"), knowndomains[domain]); 344 updateProfileComboBox(document.getElementById("cobprofileselection"), knowndomains[domain]); 345 } 346 347 function updateProfileComboBox(profilecombo, options) { 265 348 profilecombo.options.length=0; 266 for (var profile in knowndomains[domain]) {349 for (var profile in options) { 267 350 var option = document.createElement('option'); 268 option.text = option.value = knowndomains[domain][profile];351 option.text = option.value = options[profile]; 269 352 profilecombo.add(option, 0); 270 353 } 354 271 355 } 272 356 … … 275 359 */ 276 360 function addParty() { 361 addNormalParty(); 362 addCobParty(); 363 updatePartyProfileTable(); // what, MVC? 364 } 365 366 function addNormalParty() { 277 367 var partycombo = document.getElementById("partyselection"); 278 368 var profilecombo = document.getElementById("profileselection"); 369 var filteroptions = document.getElementById("filter").value; 279 370 280 371 if (partycombo.options.length==0) { … … 286 377 return; 287 378 } 379 380 if (filteroptions!="") { 381 filteroptions="?"+filteroptions; 382 } 288 383 var newpartyprof = {}; 289 290 newpartyprof["party"]={"partyref":partycombo.options[partycombo.selectedIndex].value, 384 newpartyprof["party"]={"partyref":partycombo.options[partycombo.selectedIndex].value , 291 385 "parameters":parameters }; 292 newpartyprof["profile"]=profilecombo.options[profilecombo.selectedIndex].value ;386 newpartyprof["profile"]=profilecombo.options[profilecombo.selectedIndex].value +filteroptions; 293 387 294 388 partyprofiles.push(newpartyprof) 295 updatePartyProfileTable(); // what, MVC? 296 } 389 } 390 391 392 function addCobParty() { 393 // we assume a sensible default has been loaded into the combo and set, 394 // regardless it being invisible 395 var partycombo = document.getElementById("cobpartyselection"); 396 if (partycombo.options.length==0) { 397 alert("Please set cpb partier server and select a party"); 398 return; 399 } 400 401 var newpartyprof = {}; 402 if (getAdvancedCobSettings()) { 403 var profilecombo = document.getElementById("cobprofileselection"); 404 var filteroptions = document.getElementById("cobfilter").value; 405 406 if (profilecombo.options.length==0) { 407 alert("Please set a cob profile"); 408 return; 409 } 410 if (filteroptions!="") { 411 filteroptions="?"+filteroptions; 412 } 413 newpartyprof["party"]={"partyref":partycombo.options[partycombo.selectedIndex].value , 414 "parameters":parameters }; 415 newpartyprof["profile"]=profilecombo.options[profilecombo.selectedIndex].value +filteroptions; 416 } else { 417 var profilecombo = document.getElementById("profileselection"); 418 newpartyprof["party"]={"partyref":partycombo.options[partycombo.selectedIndex].value , 419 "parameters":{} }; 420 newpartyprof["profile"]=profilecombo.options[profilecombo.selectedIndex].value; 421 } 422 cobpartyprofiles.push(newpartyprof) 423 } 424 297 425 298 426 /** updates the party and profiles table, to match the #partyprofiles list. */ … … 305 433 var cell2 = row.insertCell(-1); 306 434 var cell3 = row.insertCell(-1); 435 var cell4 = row.insertCell(-1); 436 var cell5 = row.insertCell(-1); 437 var cell6 = row.insertCell(-1); 438 307 439 cell1.innerHTML = partyprofiles[pp]["party"]["partyref"]; 308 440 cell2.innerHTML = JSON.stringify(partyprofiles[pp]["party"]["parameters"]); 309 441 cell3.innerHTML = partyprofiles[pp]["profile"]; 442 cell4.innerHTML = cobpartyprofiles[pp]["party"]["partyref"]; 443 cell5.innerHTML = JSON.stringify(cobpartyprofiles[pp]["party"]["parameters"]); 444 cell6.innerHTML = cobpartyprofiles[pp]["profile"]; 310 445 } 311 446 … … 372 507 } 373 508 509 function getSelectedProtocol() { 510 var protocolcombo = document.getElementById("selectedprotocol"); 511 return protocolcombo.options[protocolcombo.selectedIndex].value; 512 } 374 513 /** 375 514 @return a json request package for the run server 376 515 */ 377 516 function makeRequest() { 517 518 if (getSelectedProtocol()=="SHAOP") { 519 return makeShaopRequest(); 520 } else { 521 return makeSaopRequest(); 522 } 523 } 524 525 /** 526 @return a SAOP request 527 */ 528 function makeSaopRequest() { 378 529 var deadline={}; 379 530 var value = document.getElementById("deadlinevalue").value; … … 386 537 } 387 538 388 389 539 return JSON.stringify({"SAOPSettings": { "participants": partyprofiles, "deadline":deadline }}); 390 391 } 392 540 } 541 542 /** 543 @return a SHAOP request 544 */ 545 function makeShaopRequest() { 546 var deadline={}; 547 var value = document.getElementById("deadlinevalue").value; 548 var dtypecombo = document.getElementById("deadlinetype"); 549 if (dtypecombo.options[dtypecombo.selectedIndex].value=="TIME") { 550 deadline["deadlinetime"] = { "durationms": 1000*value}; 551 } else { 552 // ROUNDS 553 deadline["deadlinerounds"] = {"rounds": value, "durationms":10000}; 554 } 555 556 var parties=[]; 557 for (let i=0; i< partyprofiles.length; i++) { 558 var group={}; 559 group['shaop'] = partyprofiles[i]; 560 group['cob'] = cobpartyprofiles[i]; 561 562 parties.push(group); 563 } 564 return JSON.stringify({"SHAOPSettings": { "participants": parties, "deadline":deadline }}); 565 } 566 393 567 394 568 /** … … 396 570 */ 397 571 function init() { 572 selectProtocol(); 398 573 document.getElementById("partiesserverurl").value =window.location.hostname+":8080/partiesserver-1.1.0" 399 574 document.getElementById("profilesserverurl").value =window.location.hostname+":8080/profilesserver-1.1.0" … … 407 582 408 583 584 585 586 409 587 </script> 410 588 -
src/main/webapp/newtournament.xhtml
r7 r8 30 30 <br /> 31 31 <div id="box" class="box"> 32 Session Protocol settings <br /> Session Protocol: <select> 32 Session Protocol settings <br /> Session Protocol: 33 <select id="protocolselection"> 33 34 <option value="SAOP">SAOP</option> 34 </select> <br /> Deadline: <input type="number" id="deadlinevalue" 35 <option value="SHAOP">SHAOP</option> 36 </select> 37 38 <br /> Deadline: <input type="number" id="deadlinevalue" 35 39 name="deadline" min="1" max="10000" value="10" /> <select 36 40 id="deadlinetype"> 41 <option value="ROUNDS">rounds</option> 37 42 <option value="TIME">seconds</option> 38 <option value="ROUNDS">rounds</option>39 43 </select> 40 44 </div> … … 52 56 Profile: <select id="profileselection"> 53 57 <!-- <option>Waiting for partiesserver</option> --> 54 </select> <br /> <br /> 58 </select> 59 Filter: <input type="text" id="filter" value="" maxlength="40" /> 60 61 <br /> <br /> 55 62 56 63 <table id="profiles"> … … 304 311 function addProfile() { 305 312 var profilecombo = document.getElementById("profileselection"); 306 313 307 314 if (profilecombo.options.length==0) { 308 315 alert("Please set domain/profile server and select a domain and a profile"); 309 316 return; 310 317 } 311 profiles.push(profilecombo.options[profilecombo.selectedIndex].value) 318 var filteroptions = document.getElementById("filter").value; 319 if (filteroptions!="") { 320 filteroptions="?"+filteroptions; 321 } 322 323 profiles.push(profilecombo.options[profilecombo.selectedIndex].value + filteroptions) 312 324 updateProfileTable(); // what, MVC? 313 325 } … … 327 339 /** 328 340 start the tournament as currently set on this page. 329 We need to send a TournamentSettings object to the server, which typically looks like this 330 but is protocol dependent (currently we do SAOP) 331 341 We need to send a TournamentSettings object to the server, which typically looks like this with SAOP 342 <code> 332 343 {"AllPermutationsSettings":{"parties":["party1","party2"], 333 344 "profiles":["profile1","profile2","profile3"], … … 335 346 "partiesPerSession":2, 336 347 "sessionsettings":{"SAOPSettings":{"participants":[],"deadline":{"deadlinetime":{"durationms":10}}}}}} 337 348 </code> 338 349 participants are already in the global partyprofiles dictionary 350 351 With SHAOP, it looks like this 352 <code> 353 { 354 "AllPermutationsSettings": { 355 "parties": [ { "partyref": "classpath:geniusweb.exampleparties.simpleshaop.ShaopParty", "parameters": { } }, 356 { "partyref": "classpath:geniusweb.exampleparties.randomparty.RandomParty", "parameters": { }} 357 ], 358 "reuseParties": false, 359 "profiles": [ "prof1?partial=10", "prof2?partial=15"], 360 "partiesPerSession": 2, 361 "sessionsettings": { "SHAOPSettings": { 362 "participants": [ ], 363 "deadline": { "deadlinerounds": { "rounds": 10, "durationms": 10000 } } } } } } 364 </code> 339 365 */ 340 366 function start() { … … 380 406 deadline["deadlinerounds"] = {"rounds": value, "durationms": 10000}; 381 407 } 382 383 408 var reuseParties = document.getElementById("reuseparties").checked; 384 var sessionSettings = {"SAOPSettings":{"participants":[],"deadline":deadline}}; 409 410 var protocolcombobox = document.getElementById("protocolselection"); 411 var protocol = protocolcombobox.options[protocolcombobox.selectedIndex].value; 412 var header=protocol+"Settings"; 413 414 // create S(H)AOPSettings. [header] is a weird ECMA script workaround for javascript issue. 415 var sessionSettings = { [header]:{"participants":[],"deadline":deadline}}; 385 416 return JSON.stringify({"AllPermutationsSettings":{"parties":parties,"profiles":profiles,"reuseParties":reuseParties,"partiesPerSession":2,"sessionsettings":sessionSettings}}); 386 417 } … … 390 421 */ 391 422 function init() { 392 document.getElementById("partiesserverurl").value =window.location.hostname+":8080/partiesserver-1.1.0" 393 document.getElementById("profilesserverurl").value =window.location.hostname+":8080/profilesserver-1.1.0" 423 document.getElementById("partiesserverurl").value =window.location.hostname+":8080/partiesserver-1.1.0"; 424 document.getElementById("profilesserverurl").value =window.location.hostname+":8080/profilesserver-1.1.0"; 394 425 395 426 -
src/main/webapp/style.css
r1 r8 6 6 table { 7 7 border: 1px solid black; 8 border-collapse: collapse; 9 border: 1px solid black; 8 #border-collapse: collapse; 10 9 } 11 10
Note:
See TracChangeset
for help on using the changeset viewer.