Hi,
I recently moved to a new server and downloaded the new APE version
from the website. before all worked fine but now I am getting a
UNKNOWN_CHANNEL 401 error.
I can't figure out what is going wrong, hopefully someone here can
help me.
ServerSide JS:
Ape.registerCmd("highscores", false, function(params, infos) {
if (params.password == Ape.config("highscore.conf", "password")) {
if ($defined(params.channel) && $defined(params.data) &&
$defined(params.raw)) {
var chan = Ape.getChannelByName('highscores');
if (!$defined(chan))
return ["401", "UNKNOWN_CHANNEL"];
chan.userslist.each(function(user) {
params.friends = user.friends;
params.userid = user.getProperty('id');
if(in_array(user.getProperty('id'), user.friends)) {
user.pipe.sendRaw('highscore', { from:
user.getProperty('id'), content: params.data });
}
});
//chan.pipe.sendRaw(params.raw, params.data);
return{"name":"pushed","data":{"value":"ok"}};
} else {
return 0;
}
} else {
return ["400", "BAD_PASSWORD"];
}
});
var userlist = new $H;
Ape.registerHookCmd("connect", function(params, cmd) {
if (!$defined(params.name))
return 0;
cmd.user.setProperty('name', params.name);
cmd.user.setProperty('id', params.userid);
cmd.user.friends = params.friends;
return 1;
});
Ape.addEvent('adduser', function(user) {
userlist.set(user.getProperty('name').toLowerCase(), true);
});
Ape.addEvent('deluser', function(user) {
userlist.erase(user.getProperty('name').toLowerCase());
});
function in_array(item, array) {
for(var i = 0; i < array.length; i++) {
if(array[i] == item)
return true;
}
return false;
}
ClientSide JS:
var client = new APE.Client();
APE.Config.scripts = [APE.Config.baseUrl + '/Build/uncompressed/
apeCoreSession.js'];
function InitializeHighscore( sIdentifier, sChannel, sUsername,
nUserId, sKey, sBuddiesJSON ){
sBuddiesJSON = eval(sBuddiesJSON);
client.addEvent('load', function(){
client.core.start({'name':''+sUsername
+'','userid':nUserId,'friends':sBuddiesJSON});
});
client.onRaw('highscore', function(aRaw, aPipe) {
console.log('New highscore');
var bShowScore = false;
var bIsTopScore = false;
if( aRaw.data.content.message.scoreinfo.istopscore == "true" )
{
bIsTopScore = true;
}
if( nUserId == aRaw.data.content.message.scoreinfo.userid ){
sDoppelMeKey = aRaw.data.content.message.scoreinfo.avatar !
= 0 ? aRaw.data.content.message.scoreinfo.avatar : '';
// magic happens here
}
});
client.addEvent('ready', function() {
if (client.core.options.restore) {
//If it's a session restoration, ask the APE server for
the custom session 'key1'
client.core.getSession('key', function(resp) {
console.log('ready : ', resp.data.sessions.key);
});
} else {
client.core.setSession({'key':''+sKey+''});
}
client.core.join( sChannel );
});
// reload on disconnect
client.onError('004', function() {
client.core.clearSession();
client.core.initialize(client.core.options);
});
client.load();
}
Post to APE server:
Array ( [0] => Array ( [cmd] => highscores [params] => Array
( [password] => testpasswd [raw] => postmsg [channel] => highscores
[data] => Array ( [message] => Array ( [type] => highscore [scoreinfo]
=> Array ( [score] => 29000 [position] => 1 [istopscore] => false
[userid] => 1 [username] => Username[sanitizedusername] => username
[avatar] => key ) ) ) ) ) )
What causes the problem?
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/