@@ -26,7 +26,7 @@ class RKernel {
26
26
private request ( obj : any ) {
27
27
if ( this . socket ) {
28
28
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 } ` ) ;
30
30
}
31
31
}
32
32
@@ -89,46 +89,50 @@ class RKernel {
89
89
public async eval ( cell : vscode . NotebookCell ) : Promise < REvalOutput > {
90
90
if ( this . socket ) {
91
91
this . request ( {
92
- uri : cell . uri ,
92
+ uri : cell . uri . toString ( ) ,
93
93
time : Date . now ( ) ,
94
94
expr : cell . document . getText ( ) ,
95
95
} ) ;
96
96
}
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
+ // }
132
136
}
133
137
}
134
138
0 commit comments