Closed nponeccop closed 8 years ago
Looks like there is no function for tuple (104) in n2o.js
.
https://github.com/synrc/n2o/blob/d867186cd965ff4dfed8b8c6f291ef689f0a3e30/priv/n2o.js#L20
We use 104 type in client.js.
onMessage
function of client.js (where we use 104
) is to be removed, isn't it?
Ok. But after removing it we've got another issue in n2o.js
.
protos = [ $client, undefined ];
$bert
defined after protos
declaration.
After moving protos
and N2O_start()
definition to bottom of this file there are no errors.
However, onmessage
handler does not work properly until fix in $io
:
try { eval(utf8_dec(r.v[1].v)); ... // before
try { eval(utf8_dec(r.v[2].v)); ... // after
It fixed chat. If it is OK I would make a PR.
Files in static/
cannot be changed as they are taken from the upstream.
Haskell code should be changed instead. So the format is compatible between Erlang and Haskell versions of n2o.
https://github.com/nponeccop/n2o.hs/blob/63d1ad4babfa67302e2239a38f3ccfbf89b3e08f/src/Network/N2O.hs#L28 - this line seem to be relevant. If it tries to evaluate [1]
then you should try deleting NilTerm
Actually, there is check for object length = 3 in n2o.js
: https://github.com/synrc/n2o/blob/a141e698227777404f8da79cdae3f7f4f9314543/priv/n2o.js#L28
So I replace order of the second and the third terms on server-side. And it actually works.
Currently a homegrown
$bert.on
is used:https://github.com/nponeccop/n2o.hs/blob/master/sample/client.js#L23-L50
However, this code is already in n2o.js:
https://github.com/nponeccop/n2o.hs/blob/master/static/n2o.js#L28-L36
So the code is redundant and should be removed