Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
.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.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);
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.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);
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);
const server = net.createServer((socket: net.Socket) => {
server.close();
connectResolve({
reader: new rpc.SocketMessageReader(socket, encoding),
writer: new rpc.SocketMessageWriter(socket, encoding)
});
});
server.on('error', reject);
export function createSocketConnection(outSocket: net.Socket, inSocket: net.Socket, onDispose: () => void): IConnection {
const reader = new SocketMessageReader(outSocket);
const writer = new SocketMessageWriter(inSocket);
return createConnection(reader, writer, onDispose);
}