@@ -26,7 +26,7 @@ class RKernel {
2626 private request ( obj : any ) {
2727 if ( this . socket ) {
2828 const json = JSON . stringify ( obj ) ;
29- this . socket . write ( `Content-Length: ${ json . length } \n${ json } \n ` ) ;
29+ this . socket . write ( `Content-Length: ${ json . length } \n${ json } ` ) ;
3030 }
3131 }
3232
@@ -89,46 +89,50 @@ class RKernel {
8989 public async eval ( cell : vscode . NotebookCell ) : Promise < REvalOutput > {
9090 if ( this . socket ) {
9191 this . request ( {
92- uri : cell . uri ,
92+ uri : cell . uri . toString ( ) ,
9393 time : Date . now ( ) ,
9494 expr : cell . document . getText ( ) ,
9595 } ) ;
9696 }
97- if ( this . process ) {
98- const client = net . createConnection ( { host : '127.0.0.1' , port : this . port } , ( ) => {
99- console . log ( `uri: ${ cell . uri } , connect` ) ;
100- const request = JSON . stringify ( {
101- time : Date . now ( ) ,
102- expr : cell . document . getText ( ) ,
103- } ) . concat ( '\n' ) ;
104- console . log ( `uri: ${ cell . uri } , write: ${ request } ` ) ;
105- client . write ( request ) ;
106- } ) ;
107-
108- client . on ( 'end' , ( ) => {
109- console . log ( `uri: ${ cell . uri } , end` ) ;
110- } ) ;
111-
112- return new Promise ( ( resolve , reject ) => {
113- client . on ( 'data' , ( data ) => {
114- const response = data . toString ( ) ;
115- console . log ( `uri: ${ cell . uri } , data: ${ response } ` ) ;
116- client . end ( ) ;
117- const output : REvalOutput = JSON . parse ( response ) ;
118- resolve ( output ) ;
119- } ) ;
120-
121- client . on ( 'error' , ( err ) => {
122- console . log ( `uri: ${ cell . uri } , error: ${ err . name } , ${ err . message } ` ) ;
123- reject ( {
124- type : 'error' ,
125- result : [
126- err . message
127- ] ,
128- } ) ;
129- } ) ;
130- } ) ;
131- }
97+ return {
98+ type : 'text' ,
99+ result : 'test' ,
100+ } ;
101+ // if (this.process) {
102+ // const client = net.createConnection({ host: '127.0.0.1', port: this.port }, () => {
103+ // console.log(`uri: ${cell.uri}, connect`);
104+ // const request = JSON.stringify({
105+ // time: Date.now(),
106+ // expr: cell.document.getText(),
107+ // }).concat('\n');
108+ // console.log(`uri: ${cell.uri}, write: ${request}`);
109+ // client.write(request);
110+ // });
111+
112+ // client.on('end', () => {
113+ // console.log(`uri: ${cell.uri}, end`);
114+ // });
115+
116+ // return new Promise((resolve, reject) => {
117+ // client.on('data', (data) => {
118+ // const response = data.toString();
119+ // console.log(`uri: ${cell.uri}, data: ${response}`);
120+ // client.end();
121+ // const output: REvalOutput = JSON.parse(response);
122+ // resolve(output);
123+ // });
124+
125+ // client.on('error', (err) => {
126+ // console.log(`uri: ${cell.uri}, error: ${err.name}, ${err.message}`);
127+ // reject({
128+ // type: 'error',
129+ // result: [
130+ // err.message
131+ // ],
132+ // });
133+ // });
134+ // });
135+ // }
132136 }
133137}
134138
0 commit comments