UNPKG

rhamt-vscode-extension

Version:

RHAMT VSCode extension

63 lines (58 loc) 2.41 kB
import { AbstractEditorDelegate } from './editorDelegate'; import { RaasClient } from 'raas-client'; import * as io from 'socket.io'; export class SocketDelegate extends AbstractEditorDelegate { private socket: io.Socket; constructor(socket: io.Socket) { super(); this.socket = socket; } listen(): void { this.socket.on('disconnect', () => { this.onDisposed.emit(undefined); }); this.socket.on('optionChanged', (msg: any) => { this.onOptionChanged.emit({id: msg.id, option: msg.option, value: msg.value}); }); this.socket.on('optionAdded', (msg: any) => { this.onOptionAdded.emit({option: msg.option, value: msg.value}); }); this.socket.on('raasClientChanged', (msg: any) => { this.onRaasClientChanged.emit({host: msg.host, port: msg.port}); }); this.socket.on('connectRaasClient', (msg: any) => { this.onConnectRaasClient.emit(undefined); }); this.socket.on('disconnectRaasClient', (msg: any) => { this.onDisconnectRaasClient.emit(undefined); }); this.socket.on('startAnalysis', (msg: any) => { this.onStartAnalaysis.emit(undefined); }); this.socket.on('cancelAnalysis', (msg: any) => { this.onCancelAnalaysis.emit(undefined); }); this.socket.on('cliChanged', (msg: any) => { this.onCliChanged.emit({id: msg.id}); }); this.socket.on('addInstallation', (msg: any) => { this.onAddInstallation.emit({location: msg.location, name: msg.name, version: msg.version}); }); this.socket.on('javaHomeChanged', (msg: any) => { this.onJavaHomeChanged.emit({location: msg.location}); }); } raasClientStarting(raasClient: RaasClient): void { this.socket.send('raasClientStarting'); } raasClientConnected(raasClient: RaasClient): void { console.log('notifying client...'); this.socket.emit('raasClientConnected', {host: raasClient.host, port: raasClient.port}); } raasClientDisconnected(raasClient: RaasClient): void { this.socket.send('raasClientDisconnected'); } unableToConnectRaasClient(raasClient: RaasClient): void { this.socket.send('unableToConnectRaasClient', JSON.stringify(raasClient)); } }