show # messages, use msgpack to compress json

This commit is contained in:
proddy
2021-06-16 20:31:35 +02:00
parent 19b37d9e0e
commit 7e7bd29c9a
9 changed files with 71 additions and 58 deletions

View File

@@ -22,6 +22,9 @@ import LogEventConsole from './LogEventConsole';
import { LogEvent, LogSettings } from './types';
import { Decoder } from '@msgpack/msgpack';
const decoder = new Decoder();
interface LogEventControllerState {
eventSource?: EventSource;
events: LogEvent[];
@@ -71,12 +74,13 @@ class LogEventController extends Component<
fetch(FETCH_LOG_ENDPOINT)
.then((response) => {
if (response.status === 200) {
return response.json();
return response.arrayBuffer();
} else {
throw Error('Unexpected status code: ' + response.status);
}
})
.then((json) => {
.then((arrayBuffer) => {
const json: any = decoder.decode(arrayBuffer);
this.setState({ events: json.events });
})
.catch((error) => {