Hi all,

I am trying to hook APE up to a 3rd party app that requires a specific
packet protocol e.g first 4 bytes must be length of packet as signed
int, next byte holds packet type id, etc.

Here is what I think I need to do to accomplish this.  I am fairly
noobish at this so just wondering if anyone has done something similar
and whether the approach below makes sense or if I  am completely off
base.

----------------------------------------------------------------------
client side - send stringified json like so:

var socket = new TCPSocket();
...
socket.send(JSON.encode(myjson));
----------------------------------------------------------------------
server side js - modify Proxy.js like so:
...
pipe.onSend = function(user, params) {
        /* "this" refer to the pipe object */
        this.link.writemypacket(Ape.base64.decode(unescape(params.msg)));
}
----------------------------------------------------------------------
server side c - add the following to libape-spidermonkey.c

APE_JS_NATIVE(apesocketclient_writemypacket)
//{
        JSString *string;
        JSBool burn = JS_FALSE;
        ape_socket *client = JS_GetPrivate(cx, obj);

        if (client == NULL) {
                return JS_TRUE;
        }

        if (!JS_ConvertArguments(cx, argc, argv, "S/b", &string)) {
                return JS_TRUE;
        }

        //add code to convert json string to char *mybin matching needed
protocol format

        sendbin(client->fd, *mybin, mybinlen, (burn == JS_TRUE ? 1 : 0),
g_ape);

        return JS_TRUE;
}

static JSFunctionSpec apesocketclient_funcs[] = {
        JS_FS("write",           apesocketclient_write, 1, 0, 0),
        JS_FS("writemypacket",   apesocketclient_writemypacket, 1, 0, 0),
        JS_FS("close",           apesocketclient_close, 0, 0, 0),
        JS_FS_END
};

-- 
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/

To unsubscribe from this group, send email to 
ape-project+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to