Hi, I thought something of this was the case. Where can I find this kind of special info? Or do I have to dig into the code for this?
Regards, 2010/4/21 Nicolas Trani <[email protected]>: > Hi, > > Yes 006 and 007 error are special error used on connect and can't be > changed. Those error have a specific behavior on the client side, when the > JSF receive one of it no more request are made. > > Regarding what you are doing instead of returning the error code 206 return > the error code 006 but change the error message to BAD_AGE > > Cheers. > > > On 20/04/2010 22:36, rsdrsd wrote: >> >> I changed nickname.js on the server side to check for age and gender. >> When I want to use some custom error codes, for example 206 it will >> catch the error, but after that it keeps trying to connect. >> >> However when i use error code 006 or 007 in the same way, it works >> good. In the example below, if I change 206 to 006 it works good? I >> really can't figure it out why it doesn't work, because it should >> work. >> >> Is there maybe something special to error code 006 or 007? >> >> Client side: >> APE.Chat = new Class({ >> >> Extends: APE.Client, >> >> Implements: Options, >> >> options:{ >> container: null, >> container: document.body >> }, >> >> initialize: function(options){ >> this.setOptions(options); >> >> this.els = {}; >> this.currentPipe = null; >> >> this.onRaw('data',this.rawData); >> this.onCmd('send',this.cmdSend); >> >> this.onError('004',this.reset); >> this.onError('206',this.setName); >> this.onError('006',this.setName); >> this.onError('007',this.setName); >> >> >> this.addEvent('load',this.start); >> this.addEvent('ready',this.createChat); >> this.addEvent('uniPipeCreate',this.setPipeName); >> this.addEvent('uniPipeCreate',this.createPipe); >> this.addEvent('multiPipeCreate',this.createPipe); >> this.addEvent('userJoin',this.createUser); >> this.addEvent('userLeft',this.deleteUser); >> }, >> >> setName: function(errorRaw){ >> this.els.setName = {}; >> this.els.setName.div = new Element('div',{ >> 'class' : 'setname' >> }).inject(this.options.container) >> >> this.els.setName.form = new Element('form',{ >> 'class' : 'setnameform' >> }).inject(this.els.setName.div); >> >> this.els.setName.form.addEvent('submit',function(event){ >> event.stop(); >> this.options.name = >> this.els.setName.nameInput.get('value'); >> this.options.age = >> this.els.setName.ageInput.get('value'); >> this.options.gender = >> this.els.setName.genderSelect.get('value'); >> this.els.setName.div.dispose(); >> this.start(); >> }.bindWithEvent(this)); >> this.els.setName.form.appendText('Voer een gebruikersnaam >> in: '); >> this.els.setName.nameInput = new Element('input',{'class' : >> 'setnameinput'}).inject(this.els.setName.form); >> new Element('br').inject(this.els.setName.form); >> this.els.setName.form.appendText('Voer leeftijd in: '); >> this.els.setName.ageInput = new Element('input',{'class' : >> 'setageinput'}).inject(this.els.setName.form); >> new Element('br').inject(this.els.setName.form); >> this.els.setName.form.appendText('Kies geslacht: '); >> this.els.setName.genderSelect = new >> Element('select',{'class' : >> 'setgenderselect'}).inject(this.els.setName.form); >> new Element('option',{'value' : 'm','text' : >> 'Man'}).inject(this.els.setName.genderSelect); >> new Element('option',{'value' : 'f','text' : >> 'Vrouw'}).inject(this.els.setName.genderSelect); >> new Element('option',{'value' : 'c','text' : >> 'Stel'}).inject(this.els.setName.genderSelect); >> new Element('option',{'value' : 'x','text' : >> 'ee'}).inject(this.els.setName.genderSelect); >> new Element('br').inject(this.els.setName.form); >> this.els.setName.button = new Element('input',{ >> 'class' : 'setnamesubmit', >> 'type' : 'submit', >> 'value' : 'Inloggen' >> }).inject(this.els.setName.form) >> >> var error; >> >> if (errorRaw) { >> alert(errorRaw.data.code); >> if (errorRaw.data.code == 206) error = >> '<li>Ongeldige leeftijd!</ >> li>'; >> if (errorRaw.data.code == 007) error = '<li>Deze >> gebruikersnaam is >> al in gebruik!</li>'; >> if (errorRaw.data.code == 006) error = >> '<li>Onjuiste >> gebruikersnaam, de gebruikersnaam mag alleen uit a-z en 0-9 bestaan!</ >> li>'; >> if (error) { >> this.els.setName.error = new >> Element('ul',{'class' : >> 'setnameerror','html': error}).inject(this.els.setName.div,'top'); >> } >> } >> }, >> >> start: function(){ >> if (!(this.options.name&& this.options.age&& >> this.options.gender) >> && !this.core.options.restore) { >> this.setName(); >> } else { >> //console.log('p '); >> var opts = {'sendStack' : false,'request' : >> 'stack'}; >> >> this.core.start({'name' : this.options.name,'age' : >> this.options.age,'gender' : this.options.gender},opts); >> >> if (this.core.options.restore) { >> >> this.core.getSession('currentPipe',function(response) { >> >> this.setCurrentPipe(response.data.sessions.currentPipe); >> }.bind(this),opts); >> } >> this.core.request.stack.send(); >> } >> }, >> >> setPipeName: function(pipe,options) { >> if (options.name) { >> pipe.name = options.name; >> return; >> } >> if (options.from) { >> pipe.name = options.from.properties.name; >> } else { >> pipe.name = options.pipe.properties.name; >> } >> }, >> >> getCurrentPipe: function(){ >> return this.currentPipe; >> }, >> >> setCurrentPipe: function(pubid,save){ >> save = !save; >> if (this.currentPipe){ >> this.currentPipe.els.tab.addClass('unactivetab'); >> this.currentPipe.els.container.addClass('hide'); >> } >> this.currentPipe = this.core.getPipe(pubid); >> this.currentPipe.els.tab.removeClass('notifytab'); >> this.currentPipe.els.tab.removeClass('unactivetab'); >> this.currentPipe.els.container.removeClass('hide'); >> this.scrollMsg(this.currentPipe); >> if (save) this.core.setSession({'currentPipe' : >> this.currentPipe.getPubid()}); >> return this.currentPipe; >> }, >> >> cmdSend: function(data,pipe){ >> this.writeMessage(pipe,data.msg,this.core.user); >> }, >> >> rawData: function(raw,pipe){ >> this.writeMessage(pipe,raw.data.msg,raw.data.from); >> }, >> >> parseMessage: function(message){ >> return decodeURIComponent(message); >> }, >> >> notify: function(pipe){ >> pipe.els.tab.addClass('notifytab'); >> }, >> >> scrollMsg: function(pipe){ >> var scrollSize = pipe.els.messages.getScrollSize(); >> pipe.els.messages.scrollTo(0,scrollSize.y); >> }, >> >> writeMessage: function(pipe,message,from){ >> if (pipe.lastMsg&& pipe.lastMsg.from.pubid == from.pubid){ >> var cnt = pipe.lastMsg.el; >> } else { >> var msg = new Element('div',{'class' : 'message'}); >> var cnt = new Element('div',{'class' : >> 'usermessages'}).inject(msg); >> if (from) { >> new Element('div',{'class' : 'from','text' >> : >> from.properties.name}).inject(msg,'top'); >> } >> msg.inject(pipe.els.messages); >> } >> new Element('div',{ >> 'text' : this.parseMessage(message), >> 'class' : 'usermessage' >> }).inject(cnt); >> >> this.scrollMsg(pipe); >> >> pipe.lastMsg = {from : from,el : cnt}; >> >> if (this.getCurrentPipe().getPubid() != pipe.getPubid()){ >> this.notify(pipe); >> } >> }, >> >> createUser: function(user,pipe){ >> user.el = new Element('div',{ >> 'class' : 'user' >> }).inject(pipe.els.users); >> >> new Element('a',{ >> 'text' : user.properties.name + '(' + >> user.properties.age + ')', >> 'href' : 'javascript:void(0)', >> 'events' : { >> 'click' : >> function(ev,user) { >> if (this.core.user.pubid != >> user.pubid) { >> >> this.core.getPipe(user.pubid) >> >> this.setCurrentPipe(user.pubid); >> } >> }.bindWithEvent(this,[user]) >> } >> }).inject(user.el,'inside'); >> }, >> >> deleteUser: function(user,pipe){ >> user.el.dispose(); >> }, >> >> createPipe: function(pipe,options){ >> pipe.els = {}; >> >> pipe.els.container = new Element('div',{ >> 'class' : 'pipe hide' >> }).inject(this.els.pipeContainer); >> >> pipe.els.messages = new Element('div',{'class' : >> 'messages'}).inject(pipe.els.container,'inside'); >> >> if (pipe.users) { >> pipe.els.userList = new Element('div',{ >> 'class' : 'userlist' >> }).inject(pipe.els.container); >> >> pipe.els.users = new Element('div',{ >> 'class' : 'users' >> }).inject(pipe.els.userList); >> } >> >> pipe.els.tab = new Element('div',{ >> 'class' :'tab unactivetab' >> }).inject(this.els.tabContainer); >> >> new Element('a',{ >> 'text' : pipe.name, >> 'href' : 'javascript:void(0)', >> 'events' : { >> 'click' : function(pipe) { >> >> this.setCurrentPipe(pipe.getPubid()) >> }.bind(this,[pipe]) >> } >> }).inject(pipe.els.tab); >> >> this.setCurrentPipe(pipe.getPubid()); >> }, >> >> createChat: function() { >> this.els.pipeContainer = new Element('div',{'id' : >> 'pipes'}); >> this.els.pipeContainer.inject(this.options.container); >> >> this.els.actionContainer = new Element('div',{'id' : >> 'actions'}).inject(this.options.container,'after'); >> >> this.els.tabContainer = new Element('div',{'id' : >> 'tabs'}).inject(this.els.actionContainer); >> this.els.sendContainer = new Element('div',{'id' : >> 'send'}).inject(this.els.actionContainer); >> >> this.els.sendForm = new Element('form',{ >> 'class' : 'sendform', >> 'events' : { >> 'submit' : function(event) { >> event.stop(); >> var val = >> this.els.sendInput.get('value'); >> if (val != ''){ >> >> this.getCurrentPipe().send(val); >> >> this.els.sendInput.set('value',''); >> } >> }.bindWithEvent(this) >> } >> }).inject(this.els.sendContainer); >> >> this.els.sendInput = new Element('input',{ >> 'type' : 'text', >> 'id' : 'sendinput', >> 'autocomplete' : 'off' >> }).inject(this.els.sendForm); >> >> this.els.sendSubmit = new Element('input',{ >> 'type' : 'submit', >> 'id' : 'sendsubmit', >> 'value' : 'Versturen' >> }).inject(this.els.sendForm); >> >> }, >> >> reset: function(){ >> this.core.clearSession(); >> if (this.els.pipeContainer){ >> this.els.pipeContainer.dispose(); >> this.els.actionContainer.dispose(); >> } >> this.core.initialize(this.core.options); >> } >> }); >> >> >> Serverside: >> var userlist = new $H; >> >> Ape.registerHookCmd("connect", function(params, cmd) { >> if (!$defined(params)) return 0; >> if (!$defined(params.name)) return 0; >> if (userlist.has(params.name.toLowerCase())) return ["007", >> "NICK_USED"]; >> if (params.name.length> 16 || params.name.test('[^a-zA- >> Z0-9]', 'i')) return ["006", "BAD_NICK"]; >> if (params.age.toInt()< 1) return ["206", "BAD_AGE"]; >> >> cmd.user.setProperty('name',params.name); >> cmd.user.setProperty('age',params.age); >> cmd.user.setProperty('gender',params.gender); >> 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()); >> }); >> >> > > > -- > Nicolas Trani - Web engineer > Weelya - Improve the web > 32 rue du faubourg boutonnet > 34090 Montpellier > Tel: 04 67 169 778 - Fax: 09 57 91 99 91 > http://www.weelya.com > http://www.ape-project.org > > -- > 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/ > -- Met vriendelijke groet, Ruben Docter -- 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/
