Open monicanagent opened 5 years ago
I'm having an issue joining games. Both players show as connected and are notified of each-other joining. Tables show up but if I try to join a table, I get:
_CPSmartContract.js:115
Owner's player object not found in players array.
Desktop main.js:
const {app, BrowserWindow} = require('electron')
app.commandLine.appendSwitch('proxy-server', 'socks5://127.0.0.1:9050')
I'm having an issue joining games. Both players show as connected and are notified of each-other joining. Tables show up but if I try to join a table, I get:
_CPSmartContract.js:115
Owner's player object not found in players array.
Desktop main.js:
const {app, BrowserWindow} = require('electron') app.commandLine.appendSwitch('proxy-server', 'socks5://127.0.0.1:9050')
I'll try using your proxy-server
approach. Simple and elegant (I'm assuming it works). I didn't include details but "Tor support" was also intended to incorporate the automatic creation of an .onion
service, with optional Tor binaries installation, in the UI as another connection option. This would require some additional work though.
In the meantime ...
There may be two things going on here:
It's been a while since I've looked at this code but if I remember correctly, the contract is created by the table owner/creator (this is done in the browser/client) and must include the private IDs of all players that have joined the table. Once the contract is created, players must all agree to it before the game can begin (this keeps the contract separate from the table logic).
Try updating getPlayer
in CP_SmartContract.js to see which of these conditions may be causing the issue:
function getPlayer(contract, privateID) {
console.log ("Looking for player: "+privateID);
console.log ("Registered contract players:");
console.dir (contract.players);
for (var count=0; count < contract.players.length; count++) {
if (contract.players[count].privateID == privateID) {
return (contract.players[count]);
}
}
return (null);
}
If the joining player's private ID returns null
, that indicates a problem -- the player trying to join - you - has not been specified in the contract.
You can also try looking at the "new" switch statement in CP_SmartContract.js to see how the server is receiving the contract data from the table owner/creator:
switch (requestParams.action) {
case "new":
console.log ("Creating new contract:");
console.dir (requestParams.contract);
var gameContracts = namespace.cp.getContractsByPID(privateID);
if (gameContracts.length > 10) {
sendError(JSONRPC_ERRORS.ACTION_DISALLOWED, "Too many open game contracts.", sessionObj);
return(false);
}
If all player's PIDs don't appear in the contract at this point, the problem will be in the client code since that's where the contract is generated (the CP_SmartContract.js
"new" API call only registers and validates it):
paramsObj.contract.players = this.getPlayers(false, false);
console.log ("Players in new contract:");
console.dir (paramsObj.contract.players);
Keep in mind that this output will be in the client JavaScript console (web browser or Electron window). Are all expected players' PIDs present in the array?
Add support for user-configurable peer-to-peer networking via Tor and onions services.
Additional details to follow.