Skip to content

Commit

Permalink
left event now give an user object with public properties [APE-Projec…
Browse files Browse the repository at this point in the history
…t#13 state:resolved]
  • Loading branch information
paraboul committed Oct 22, 2009
1 parent 687f9fe commit 41f2a56
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/libape-spidermonkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ APE_JS_NATIVE(apeuser_sm_get_property)
//{
const char *property;
USERS *user = JS_GetPrivate(cx, obj);

if (user == NULL) {
return JS_TRUE;
}
Expand Down
6 changes: 1 addition & 5 deletions scripts/examples/nickname.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var userlist = new $H;
Ape.registerHookCmd("connect", function(params, infos) {
if (!$defined(params.name)) return 0;
if (userlist.has(params.name.toLowerCase())) return ["005", "NICK_USED"];
if (params.name.length > 16 || params.name.test('[^a-z0-9]', 'i')) return ["006", "BAD_NICK"];
if (params.name.length > 16 || params.name.test('[^a-zA-Z0-9]', 'i')) return ["006", "BAD_NICK"];

userlist.set(params.name.toLowerCase(), true);

Expand All @@ -14,10 +14,6 @@ Ape.registerHookCmd("connect", function(params, infos) {
};
});

Ape.addEvent('adduser', function(user) {
Ape.log(user.getProperty('name'));
});

Ape.addEvent('deluser', function(user) {
userlist.erase(user.getProperty('name').toLowerCase());
});
1 change: 0 additions & 1 deletion scripts/main.ape.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Ape.addEvent("init", function() {
include("examples/nickname.js");
//include("examples/ircserver.js");
Ape.log("[JS] ../scripts/main.ape.js loaded");

});
8 changes: 3 additions & 5 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ unsigned int checkcmd(clientget *cget, transport_t transport, subuser **iuser, a

send_raw_inline(cget->client, transport, newraw, g_ape);
} else {
//else if ((rjson = json_lookup(ijson->child, "cmd")) != NULL && rjson->jval.vu.str.value != NULL && (cmdback = (callback *)hashtbl_seek(g_ape->hCallback, rjson->jval.vu.str.value)) != NULL) {
for (ijson = ijson->jchild.child; ijson != NULL; ijson = ijson->next) {

rjson = json_lookup(ijson->jchild.child, "cmd");
//printf("valval %s\n", rjson->jval.vu.str.value);

if (rjson != NULL && rjson->jval.vu.str.value != NULL && (cmdback = (callback *)hashtbl_seek(g_ape->hCallback, rjson->jval.vu.str.value)) != NULL) {
callbackp cp;
cp.client = NULL;
Expand All @@ -159,8 +158,7 @@ unsigned int checkcmd(clientget *cget, transport_t transport, subuser **iuser, a
}

if (cmdback->need != NEED_NOTHING) {
//json_item *jchl;


if (guser == NULL) {

RAW *newraw;
Expand Down Expand Up @@ -324,7 +322,7 @@ unsigned int cmd_connect(callbackp *callbacki)

clear_properties(&callbacki->properties);

return (RETURN_NOTHING);
return (RETURN_NULL);
}

callbacki->call_user = nuser;
Expand Down
8 changes: 4 additions & 4 deletions src/users.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,15 @@ void deluser(USERS *user, acetables *g_ape)
return;
}

FIRE_EVENT_NULL(deluser, user, g_ape);


left_all(user, g_ape);

FIRE_EVENT_NULL(deluser, user, g_ape);

/* kill all users connections */

clear_subusers(user);

hashtbl_erase(g_ape->hSessid, user->sessid);


g_ape->nConnected--;

Expand All @@ -209,6 +207,8 @@ void deluser(USERS *user, acetables *g_ape)

user->pipe = NULL;

/* TODO Add Event */

free(user);

user = NULL;
Expand Down

0 comments on commit 41f2a56

Please sign in to comment.