Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.socket.on('connect', () => {
const reader = new SocketMessageReader(this.socket);
const writer = new SocketMessageWriter(this.socket);
this.clientConnection = createMessageConnection(reader, writer, this.logger);
this.registerOnNotificationHandler(this.clientConnection);
this.clientConnection.listen();
resolve(this.clientConnection);
this.eventEmitter.emit('connect');
});
.createServer(client => {
client.setEncoding('utf8');
reader = new SocketMessageReader(client);
writer = new SocketMessageWriter(client);
client.on('end', () => {
socket.close();
process.exit(0);
});
const connection = createMessageConnection(reader, writer, logger);
addHandlers(connection, logger, options.configDir);
connection.listen();
})
.listen(port);
const server = net.createServer(socket => {
this.initialized = false;
server.close();
this.eventEmitter.emit('connect');
socket.on('close', () => this.onSocketClosed());
this.logger.info('langserver connection established on port ' + this.targetPort);
const reader = new SocketMessageReader(socket);
const writer = new SocketMessageWriter(socket);
this.clientConnection = createMessageConnection(reader, writer, this.logger);
this.registerOnNotificationHandler(this.clientConnection);
this.clientConnection.listen();
res(this.clientConnection);
});
server.on('error', rej);
this.socket.on('connect', () => {
const reader = new SocketMessageReader(this.socket);
const writer = new SocketMessageWriter(this.socket);
this.clientConnection = createMessageConnection(reader, writer, this.logger);
this.registerOnNotificationHandler(this.clientConnection);
this.clientConnection.listen();
this.eventEmitter.emit('connect');
});
this.socket.on('connect', () => {
const reader = new SocketMessageReader(this.socket);
const writer = new SocketMessageWriter(this.socket);
this.clientConnection = createMessageConnection(reader, writer, this.logger);
this.registerOnNotificationHandler(this.clientConnection);
this.clientConnection.listen();
resolve(this.clientConnection);
this.eventEmitter.emit('connect');
});
const server = net.createServer(socket => {
this.initialized = false;
server.close();
this.currentServer = null;
socket.on('close', () => this.onSocketClosed());
this.eventEmitter.off('changePort', server.close);
this.logger.info('langserver connection established on port ' + this.targetPort);
const reader = new SocketMessageReader(socket);
const writer = new SocketMessageWriter(socket);
this.clientConnection = createMessageConnection(reader, writer, this.logger);
this.registerOnNotificationHandler(this.clientConnection);
this.clientConnection.listen();
this.eventEmitter.emit('connect');
});
server.on('error', this.setError);
private createRpcConnection(process: LanguageServerProcess): rpc.MessageConnection {
let reader: rpc.MessageReader;
let writer: rpc.MessageWriter;
const connectionType = this.getConnectionType();
switch (connectionType) {
case 'ipc':
reader = new rpc.IPCMessageReader(process as cp.ChildProcess);
writer = new rpc.IPCMessageWriter(process as cp.ChildProcess);
break;
case 'socket':
reader = new rpc.SocketMessageReader(this.socket);
writer = new rpc.SocketMessageWriter(this.socket);
break;
case 'stdio':
reader = new rpc.StreamMessageReader(process.stdout);
writer = new rpc.StreamMessageWriter(process.stdin);
break;
default:
return Utils.assertUnreachable(connectionType);
}
return rpc.createMessageConnection(reader, writer, {
log: (..._args: any[]) => { },
warn: (..._args: any[]) => { },
info: (..._args: any[]) => { },
error: (...args: any[]) => {
this.logger.error(args);
},
export const createServerSocketTransport = (
port: number,
encoding: string = 'utf-8'
): RPCOperator => {
const socket = net.createConnection(port, '127.0.0.1');
return {
reader: new rpc.SocketMessageReader(socket, encoding),
writer: new rpc.SocketMessageWriter(socket, encoding)
};
};