sendResponse is not a function.

65 views
Skip to first unread message

Sudeep S

unread,
Jun 4, 2010, 8:38:44 AM6/4/10
to APE Project
Dear APE Team,
I want to use only the controller and HTTP hit functionality on the
JSSS. So in the main_ape.js fileI had commented the below lines
include("framework/mootools.js");
include("framework/http_auth.js");
include("commands/proxy.js");
include("utils/checkTool.js");
include("examples/move.js");
include("examples/ircserver.js");
include("examples/nickname.js");
--------------------------
The below files were letf uncommented
include("framework/userslist.js");
include("framework/Http.js");
include("commands/inlinepush.js");
include("utils/utils.js");

But on CONNECT HookCmd when Im sending a custom raw after some
validation, I'm not able to receive that raw on the client side and Im
getting an error which says TypeError: cmd.sendResponse is not a
function.

Can you please share some pointers to this.

Regards,
Sudeep Sunthankar

Sudeep Sunthankar

unread,
Jun 7, 2010, 3:42:19 AM6/7/10
to APE Project
Dear APE Team,


Im using the inline push feature with CONNECT hook command, but it gives me below error sometimes:

1) cmd.sendResponse  is not a function.
Also sometimes when I'm using the mkChan function to create a channel I do not get the CHANNEL raw back on the client side.
As mentioned earlier  I have only kept the foll 3 files below files at my server side 

include("framework/Http.js");
include("commands/inlinepush.js");


Below is the function:

Ape.registerHookCmd("CONNECT", function(params, cmd) {
    var ClientErrorResponse = "Incorrect User Name or Password";
    if (!((params.username || params.username == 'null') && (params.pwd || params.pwd == 'null'))){
        cmd.sendResponse("authfail", {"fail":"true", "response":{ "errcode":"1", "reason" : ClientErrorResponse}});
        return 0;
    }
    var authurl = "http://localhost/auth.php";
    var request = new Http(authurl);
    var cookie = "passwd="+params.pwd;
    request.setHeader('COOKIE', cookie);
    request.getContent(function(result) {
    var ret = {};
        try {
            ret = JSON.parse(result);
        } catch(e){
            Ape.log("Caught error in JSON Object Parsing, Data returned is not in Proper format")
        };
        if(ret.details.respcode == 0){
            Ape.log('Authentication Failure');
            cmd.sendResponse("authfail", {"fail":"true", "response":{ "errcode":"2", "reason":"Authentication Failure. }});
        }
        if(ret.details.respcode == 1){
            var userkeyname = 'servercookie';
            var secretname = Ape.sha1.str(decodeURIComponent(params.username));r
            var secretkey = Ape.sha1.str(userkeyname + decodeURIComponent(params.pwd));
            cmd.user.userkeyname = secretkey;
            var tmpchan = decodeURIComponent(params.pwd);
            var chan= Ape.sha1.str(tmpchan);
            var chanobj = Ape.getChannelByName(chan);
            if (!$defined(chanobj)) {
                    chanobj = Ape.mkChan(chan);
            }else{
                    Ape.log('Channel ' + chan + ' is already present ');
            }

            cmd.sendResponse("authsuccess", {"fail":"false", "response":{ "errcode":"0", "reason":"Authentication Success", "channel" : chan}});
            var url = "http://localhost/auth_fail.php";
            var request = new Http(url);
            request.set('method', 'POST');
            request.writeData('user_wrong', params.username);
            request.writeData('pwd_wrong', params.pwd);
            request.writeData('action', 'login');
            request.getContent(function(result) {
                Ape.log('Response returned is ' + result);
                var ret = {};
                try {
                    ret = JSON.parse(result);
                } catch(e){
                    Ape.log("Caught error in JSON Object Parsing, Data returned is not in Proper format")
                };
            });
            return 1;
        }
    });
});

Can you please tell me if there is anything wrong, because I am unable to fix it  and if such an issue arises when my application is live, there should be some way to debug it .

Also let me tell you that sometimes the function works properly


--
Regards,
Sudeep Sunthankar
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to ape-p...@googlegroups.com
To unsubscribe from this group, send email to
ape-project...@googlegroups.com
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/




Sudeep S

unread,
Jun 7, 2010, 9:05:25 AM6/7/10
to APE Project
Dear APE team,
Im getting the below message while trying to debug my problem. Is
there any file I'm missing out or any function that Im not using
properly
/var/ape/commands/inlinepush.js:75:ReferenceError: $defined is not
defined
/var/ape/commands/inlinepush.js:4:TypeError: cmd.sendResponse is not a
function
Inline Push problem


Thanks and Regards,
Sudeep Sunthankar
> > ape-project...@googlegroups.com<ape-project%2Bunsu...@googlegroups.com>

Anthony Catel

unread,
Jun 7, 2010, 9:16:16 AM6/7/10
to ape-p...@googlegroups.com
Hi,

Don't forget to include MooTools.
Also, I don't understand why you have a "sendResponse" error in
inlinepush since it's not used in that context.
You must not use sendResponse when you are not in "user" context (i.e. a
registerCmd with a "false" as second argument). You can use it in a
"CONNECT" hook though.

You must use the "return" syntax instead :

To send a raw :
return { "name":"rawName","data":{whateveryouwant} };

To send an error :
return ["xxx", "description"]

When you said that you don't get the "CHANNEL" raw when you call
"mkChan" it's totally normal :

- Ape.mkChan() only create a persistant channel
- You have to use user.join() to force a user to join a channel or make
him send a "JOIN" command.

Btw, you are doing it wrong in your code. Don't forget to "return -1" to
delay the connection (since you are using an async auth).

Anthony C.

Sudeep S a �crit :

Sudeep Sunthankar

unread,
Jun 7, 2010, 10:35:56 AM6/7/10
to ape-p...@googlegroups.com
Dear APE Team,

 Thanks for the feedback. Im infact using sendResponse in CONNECT hook to send the response  as below

Ape.registerHookCmd("CONNECT", function(params, cmd) {

   var ClientErrorResponse = "Incorrect User Name or Password";
   if (!((params.username || params.username == 'null') && (params.pwd ||
params.pwd == 'null'))){
       cmd.sendResponse("authfail", {"fail":"true", "response":{ "errcode":"1", "reason" : ClientErrorResponse}});

Also to send a custom raw, I'm using the same return statement which you have specified (also saw the same on the forum).

Thanks for the insight on mkChan command, I also call client.core.join which I believe sends a JOIN command on my Client side, but this depends on the above sendResponse return as I send back the channel to join in the return value as below

cmd.sendResponse("authsuccess", {"fail":"false", "response":{"errcode":"0", "reason":"Authentication Success", "channel" : chan}});

Since, I don't get the channel name I'm not able to proceed further.

What surprises me is that, till recently I was doing a load testing of APE with 10000 users and the above code was running smoothly without any issues. Its just when I rolled back the 1.0 server version, after I was unable to run the GIT version without any success, I started facing these issues.Could you give some pointers in this direction as to when we do some upgrade/downgrades we should take care of certain things.

Thanks again for the response.

Regards,
Sudeep Sunthankar



On Mon, Jun 7, 2010 at 6:46 PM, Anthony Catel <a.c...@weelya.com> wrote:
Hi,

Don't forget to include MooTools.
Also, I don't understand why you have a "sendResponse" error in inlinepush since it's not used in that context.
You must not use sendResponse when you are not in "user" context (i.e. a registerCmd with a "false" as second argument). You can use it in a "CONNECT" hook though.

You must use the "return" syntax instead :

To send a raw :
return { "name":"rawName","data":{whateveryouwant} };

To send an error :
return ["xxx", "description"]

When you said that you don't get the "CHANNEL" raw when you call "mkChan" it's totally normal :

- Ape.mkChan() only create a persistant channel
- You have to use user.join() to force a user to join a channel or make him send a "JOIN" command.

Btw, you are doing it wrong in your code. Don't forget to "return -1" to delay the connection (since you are using an async auth).

Anthony C.

Sudeep S a écrit :

Anthony Catel

unread,
Jun 7, 2010, 10:59:34 AM6/7/10
to ape-p...@googlegroups.com
I see.

cmd.sendResponse was added in 1.01 just like Ape.mkChan().

The current more stable dev version is : http://github.com/harmer/APE_Server

Anthony

Sudeep Sunthankar a �crit :

> Sudeep S a �crit :


>
> Dear APE team,
> Im getting the below message while trying to debug my
> problem. Is
> there any file I'm missing out or any function that Im not using
> properly
> /var/ape/commands/inlinepush.js:75:ReferenceError: $defined is not
> defined
> /var/ape/commands/inlinepush.js:4:TypeError: cmd.sendResponse
> is not a
> function
> Inline Push problem
>
>
> Thanks and Regards,
> Sudeep Sunthankar
>
> On Jun 7, 12:42 pm, Sudeep Sunthankar <ssudeeps...@gmail.com

> <mailto:ape-p...@googlegroups.com>


> To unsubscribe from this group, send email to
> ape-project...@googlegroups.com

> <mailto:ape-project%2Bunsu...@googlegroups.com><ape-project%2Bunsu...@googlegroups.com
> <mailto:ape-project%252Buns...@googlegroups.com>>


> 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/
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to ape-p...@googlegroups.com

> <mailto:ape-p...@googlegroups.com>


> To unsubscribe from this group, send email to
> ape-project...@googlegroups.com

> <mailto:ape-project%2Bunsu...@googlegroups.com>

Sudeep Sunthankar

unread,
Jun 8, 2010, 5:11:49 AM6/8/10
to ape-p...@googlegroups.com
Dear Team,
 
Thanks for the reposne. I have updated my APE server to latest GIT version , but I'm getting the below error
document.domain has not been set.
The value of document.domain is same as ape.conf.domain.
Do I have to update the JSF also?
One thing I have changed is the value of version to  '1.01' in the file Source/Core/APE.js


Please let me know

Thanks

--
Regards,
Sudeep Sunthankar

IS
On Mon, Jun 7, 2010 at 8:29 PM, Anthony Catel <a.c...@weelya.com> wrote:
I see.

cmd.sendResponse was added in 1.01 just like Ape.mkChan().

The current more stable dev version is : http://github.com/harmer/APE_Server

Anthony

Sudeep Sunthankar a écrit :
   Sudeep S a écrit :

Anthony Catel

unread,
Jun 8, 2010, 1:07:33 PM6/8/10
to ape-p...@googlegroups.com
Yes, you must update your JSF also.

Sudeep Sunthankar a �crit :


> Dear Team,
>
> Thanks for the reposne. I have updated my APE server to latest GIT
> version , but I'm getting the below error
> document.domain has not been set.
> The value of document.domain is same as ape.conf.domain.
> Do I have to update the JSF also?
> One thing I have changed is the value of version to '1.01' in the
> file Source/Core/APE.js
>
>
> Please let me know
>
> Thanks
>
> --
> Regards,
> Sudeep Sunthankar
>
> IS
> On Mon, Jun 7, 2010 at 8:29 PM, Anthony Catel <a.c...@weelya.com
> <mailto:a.c...@weelya.com>> wrote:
>
> I see.
>
> cmd.sendResponse was added in 1.01 just like Ape.mkChan().
>
> The current more stable dev version is :
> http://github.com/harmer/APE_Server
>
> Anthony
>

> Sudeep Sunthankar a �crit :

> Sudeep S a �crit :


>
> Dear APE team,
> Im getting the below message while trying to debug my
> problem. Is
> there any file I'm missing out or any function that Im
> not using
> properly
> /var/ape/commands/inlinepush.js:75:ReferenceError:
> $defined is not
> defined
> /var/ape/commands/inlinepush.js:4:TypeError:
> cmd.sendResponse
> is not a
> function
> Inline Push problem
>
>
> Thanks and Regards,
> Sudeep Sunthankar
>
> On Jun 7, 12:42 pm, Sudeep Sunthankar
> <ssudeeps...@gmail.com <mailto:ssudeeps...@gmail.com>

> <mailto:ssudeeps...@gmail.com

> <mailto:ssudeeps...@gmail.com> <mailto:ssudeeps...@gmail.com

> <mailto:ape-p...@googlegroups.com


> <mailto:ape-p...@googlegroups.com>>
>
> To unsubscribe from this group, send email to
> ape-project...@googlegroups.com
> <mailto:ape-project%2Bunsu...@googlegroups.com>
>

> <mailto:ape-project%2Bunsu...@googlegroups.com
> <mailto:ape-project%252Buns...@googlegroups.com>><ape-project%2Bunsu...@googlegroups.com
> <mailto:ape-project%252Buns...@googlegroups.com>
>
> <mailto:ape-project%252Buns...@googlegroups.com
> <mailto:ape-project%25252Bun...@googlegroups.com>>>


>
> 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/
>
>
>
>
> -- You received this message because you are subscribed
> to the Google
> Groups "APE Project" group.
> To post to this group, send email to
> ape-p...@googlegroups.com <mailto:ape-p...@googlegroups.com>

> <mailto:ape-p...@googlegroups.com


> <mailto:ape-p...@googlegroups.com>>
>
> To unsubscribe from this group, send email to
> ape-project...@googlegroups.com
> <mailto:ape-project%2Bunsu...@googlegroups.com>

> <mailto:ape-project%2Bunsu...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages