Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tap(([appDetail, org, space]) => {
this.cfGuid = appDetail.cloudFoundryDetails.cloudFoundry;
this.orgGuid = appDetail.cloudFoundryDetails.org;
this.spaceGuid = appDetail.cloudFoundryDetails.space;
this.applicationSource = appDetail.applicationSource;
this.applicationOverrides = appDetail.applicationOverrides;
const host = window.location.host;
const streamUrl = (
`wss://${host}/pp/${this.proxyAPIVersion}/${this.cfGuid}/${this.orgGuid}/${this.spaceGuid}/deploy` +
`?org=${org.entity.name}&space=${space.entity.name}`
);
this.inputStream = new Subject();
this.messages = websocketConnect(streamUrl, this.inputStream)
.pipe(
catchError(e => {
return [];
}),
map(message => {
const json = JSON.parse(message);
return json;
}),
filter(l => !!l),
tap((log) => {
// Deal with control messages
if (log.type !== SocketEventTypes.DATA) {
this.processWebSocketMessage(log);
}
}),
filter((log) => log.type === SocketEventTypes.DATA),
ngOnInit() {
this.connectionStatus.next(0);
if (!this.applicationService.cfGuid || !this.applicationService.appGuid) {
this.messages = NEVER;
} else {
const host = window.location.host;
const streamUrl = `wss://${host}/pp/v1/${
this.applicationService.cfGuid
}/apps/${this.applicationService.appGuid}/stream`;
const socket$ = makeWebSocketObservable(streamUrl);
socket$.pipe(catchError(e => {
this.logService.error(
'Error while connecting to socket: ' + JSON.stringify(e)
);
return [];
}),
share(),
filter(data => !!data && data.length)
);
this.messages = socket$.pipe(
switchMap((getResponses: GetWebSocketResponses) => {
this.connectionStatus.next(1);
return getResponses(new Subject());
}),
map((message: string) => message),
private setupFirehoseStream(streamUrl: string) {
const { messages, connectionStatus } = websocketConnect(
streamUrl,
new Subject()
);
this.messages = messages;
this.connectionStatus = connectionStatus;
messages.pipe(
catchError(e => {
return [];
}),
share(),
filter(l => !!l)
);
}
}
private setupFirehoseStream(streamUrl: string) {
const { messages, connectionStatus } = websocketConnect(
streamUrl,
new Subject()
);
this.messages = messages;
this.connectionStatus = connectionStatus;
messages.pipe(
catchError(e => {
return [];
}),
share(),
filter(l => !!l)
);
}
}
this.appInstanceLink = (
`/applications/${cfGuid}/${appGuid}/instances`
);
if (!cfGuid || !appGuid || !this.instanceId) {
this.messages = NEVER;
this.connectionStatus = NEVER;
} else {
const host = window.location.host;
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
const streamUrl = (
`${protocol}://${host}/pp/v1/${cfGuid}/apps/${appGuid}/ssh/${this.instanceId}`
);
this.sshInput = new Subject();
const connection = websocketConnect(
streamUrl,
this.sshInput
);
this.messages = connection.messages.pipe(
catchError(e => {
if (e.type === 'error') {
this.errorMessage = 'Error connecting to web socket';
}
return [];
}));
this.connectionStatus = connection.connectionStatus;
this.breadcrumbs$ = this.applicationService.waitForAppEntity$.pipe(
map(app => this.getBreadcrumbs(app.entity.entity)),
public connect() {
if (this.messages) {
return;
}
this.messages = websocketConnect(
environment.wsOrderApi + '/orders',
this.inputStream = new QueueingSubject()
).messages.share();
}
private setupFirehoseStream(streamUrl: string) {
const { messages, connectionStatus } = websocketConnect(
streamUrl,
new Subject()
);
this.messages = messages;
this.connectionStatus = connectionStatus;
messages.pipe(
catchError(e => {
return [];
}),
share(),
filter(l => !!l)
);
}
}