File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,9 +56,12 @@ class RKernel {
5656 if ( this . process ) {
5757 const client = net . createConnection ( { port : this . port } , ( ) => {
5858 console . log ( 'connected to server!' ) ;
59- const json = `{"time":"${ Date . now ( ) . toString ( ) } ","expr":"rnorm(3)"}\n` ;
60- console . log ( `Send: ${ json } ` ) ;
61- client . write ( json ) ;
59+ const request = JSON . stringify ( {
60+ time : Date . now ( ) ,
61+ expr : cell . document . getText ( ) ,
62+ } ) . concat ( '\n' ) ;
63+ console . log ( `Send: ${ request } ` ) ;
64+ client . write ( request ) ;
6265 } ) ;
6366
6467 client . on ( 'end' , ( ) => {
@@ -67,10 +70,12 @@ class RKernel {
6770
6871 return new Promise ( ( resolve , reject ) => {
6972 client . on ( 'data' , ( data ) => {
70- const result = data . toString ( ) ;
71- console . log ( result ) ;
73+ const response = data . toString ( ) ;
74+ console . log ( response ) ;
7275 client . end ( ) ;
73- resolve ( result ) ;
76+ const output = JSON . parse ( response ) ;
77+ const result : string [ ] = output . result ;
78+ resolve ( result . join ( '\n' ) ) ;
7479 } ) ;
7580
7681 client . on ( 'error' , ( err ) => {
You can’t perform that action at this time.
0 commit comments