This is fixed for the next beta. Thanks for pointing it out.
On Mon, Nov 17, 2014 at 1:20 PM, Henry Rich <[email protected]> wrote:
> The file is appended to the bottom of this email.
>
> To run it, open 2 J sessions and load the file. Then on one system
> execute:
>
> wd 'ws listen 3000'
>
>
> and on the other:
>
> datasocket =: wd 'ws connect ws://localhost:3000'
>
>
>
> The problem will immediately arise, as the handlers type out info lines.
> They become the last line of the display and there is no prompt.
>
> Henry
>
>
> FILE FOLLOWS
>
> require 'socket'
> coinsert 'jsocket'
>
> NB. code for server
> NB. wd 'ws listen 3000'
> wssvr_handler_z_ =: verb define
> NB.?lintonly wss0_jrx_ =: ''
> 'evt socket'=.y
> select. evt
> case. jws_onOpen_jqtide_ do. NB. onOpen
> datasocket =: socket
> smoutput 'socket connected: ' , ": socket
> case. jws_onMessage_jqtide_ do. NB. onMessage
> incomingdata_base_ wss0_jrx_
> case. do.
> smoutput 'Event ' , ": evt
> end.
> )
>
> NB. websocket client
> NB. datasocket =: wd 'ws connect ws://localhost:3000'
> NB. senddata
> wscln_handler_z_ =: verb define
> NB.?lintonly wsc0_jrx_ =: ''
> 'evt socket'=.y
> select. evt
> case. jws_onOpen_jqtide_ do. NB. onOpen
> smoutput 'connection opened'
> case. jws_onMessage_jqtide_ do. NB. onMessage
> incomingdata_base_ wsc0_jrx_
> case. do.
> smoutput 'Event ' , ": evt
> end.
> )
>
> NB. y is data to send
> NB. x is socket to send to; if omitted, use datasocket
> senddata =: 3 : 0
> assert. 0 = 4!:0 <'datasocket'
> datasocket senddata y
> :
> wd 'ws send ' , (": x) , ' *' , y
> )
>
> incomingdata =: 3 : 0
> smoutput y
> )
>
> NB. Return our IP address as a string
> whoami =: monad define
> 2 {:: sdgethostbyname 1 {:: sdgethostname ''
>
> )
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm