the reason I use pD over smoutput is that it returns what it prints without
modifying it.
I made the following change to the send line:
pD (pD 3!:1 r_jrx_) -: 3!:1 r_jrx_
pD 'serv send'; r=. 0 ". wd 'ws sendb ',(":sk),' *', 3!:1 r_jrx_
pD 0 ". wd 'ws sendb ', (":sk), ' *Alphabet:', a.
output is:
�<<
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
1
┌─────────┬─┐
│serv send│3│
└─────────┴─┘
9
meaning:
y -: pD y
still 3 bytes sent on first sendb.
Just 'Alphabet:' sent on 2nd. (Hitting byte of 0 might terminate message)
----- Original Message -----
From: bill lam <[email protected]>
To: [email protected]
Cc:
Sent: Monday, February 17, 2014 1:04:52 AM
Subject: Re: [Jprogramming] Qt websockets and doevents
I'll take a look in the jwiki entry,
I suspect you meant
pD 'serv send'; r=. 0 ". wd 'ws sendb ',(":sk),' *', 3!:1 ...
or did check what is r_jrx and the result of pD?
smoutput r_jrx_
smoutput $r_jrx_
smoutput 3!:0 r_jrx_
foo=. pD 3!:1 r_jrx_
smoutput $foo
smoutput 3!:0 foo
I think you should make sure what was being sent first.
Also QtWebsocket may interpret and convert data as utf8 text but
a. is not a legal utf8 string. I guess neither will other
websockt server/client, eg javascript, will handle raw binary data
in the same manner as J. They either use equivelent of sendb or
encode binary to plain text such as base64 in order to transmit/receive
binary data.
Вс, 16 фев 2014, Pascal Jasmin писал(а):
> thank you bill that worked.
>
> sendb may not work... or has documentation issues.
>
> modifying the demo (server handler onMessage send line) to:
>
> pD 'serv send'; r=. 0 ". wd 'ws sendb ',(":sk),' *', pD 3!:1 r_jrx_
>
> where pD =: 1!:2&2
>
> the output to the default client request is:
>
> �<<
> 0 1 2 3 4
> 5 6 7 8 9
> 10 11 12 13 14
> 15 16 17 18 19
> ┌─────────┬─┐
> │serv send│3│
> └─────────┴─┘
>
> only 3 bytes are being sent.
>
> On the client side, only 1 byte appears to be in wsc0_jrx_
>
> I assume there are 2 typos on the example for sendb at
> http://www.jsoftware.com/jwiki/Guides/JqtWebsocket
>
> should be:
> len=. 0 ". wd 'ws sendb ', socket, ' *Alphabet:', a.
> but adding the line:
> pD 0 ". wd 'ws sendb ', (":sk), ' *Alphabet:', a.
>
>
> results in 9 bytes sent
>
> There is a suggestion that sendb might not be necessary at all for J to J
> applications,
>
> "J itself does not distinguish between text and binary data, but binary data
> cannot always be represented as legal utf8 text and the remote side that
> connected to the socket may also care, use either send or sendb as
> appropriated."
>
> but only 9 bytes are sent when send instead of sendb is used too.
>
>
> ----- Original Message -----
> From: bill lam <[email protected]>
> To: [email protected]
> Cc:
> Sent: Friday, February 14, 2014 10:49:50 PM
> Subject: Re: [Jprogramming] Qt websockets and doevents
>
> Sorry, the error message was terse.
> in fact it expected either 1 ro 2 arguments for send.
> either "send socket" or "send socket data"
>
> try this
>
> wd 'ws send ', (": sk) , ' hello'
> or
> wd 'ws send ', (": sk) , ' "hello client, username:"'
> or
> wd 'ws send ', (": sk) , ' *hello client, username:'
>
> I guess the send in the demo should already use the *
>
> Пт, 14 фев 2014, Pascal Jasmin писал(а):
> > Another issue I've uncovered in single application client and server
> > communication, also applies to separate applications.
> >
> > It appears that the server receives the connect (onOpen) event first
> > (before client), but even though the server is connected, it is not safe
> > for it to send yet.
> >
> > For instance, modifying the demo file: \addons\ide\qt\demo.ijs
> >
> > in the elseif jws_onOpen section of wssvr_handler , adding the line:
> > smoutput 'serv connected'
> >
> > wd 'ws send ', (": sk) , ' hello client, username:'
> >
> >
> > (loading the file will also load a client web page app)
> >
> > Hitting connect on the web app will display following message in console:
> >
> > serv connected
> > |ws : Need socket [data]: 73313136 hello client, username:: wd
> > | (wd ::(''"_)'qer') (13!:8)3
> >
> > The previous problem I was reporting was that the client sending "too fast"
> > caused no error on send, but a disconnect. Here the server has been told
> > its connected, and has a socket number, but this weird error. Some
> > suggestions:
> >
> > Perhaps the connect event could be delayed until the 2 sides are "really
> > connected" ?
> > send should return _1 in above case?
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm