improvements on osc input
This commit is contained in:
@ -9,9 +9,18 @@ export interface OSCMessage {
|
||||
export let outputSocket = new WebSocket("ws://localhost:3000");
|
||||
export let inputSocket = new WebSocket("ws://localhost:3001");
|
||||
|
||||
inputSocket.onmessage= function (event) {
|
||||
console.log("Received: ", event.data);
|
||||
}
|
||||
// Queue of 1000 last messages
|
||||
export let oscMessages : any[] = [];
|
||||
|
||||
inputSocket.addEventListener('message', (event) => {
|
||||
let data = JSON.parse(event.data);
|
||||
if (oscMessages.length > 1000) {
|
||||
oscMessages.shift();
|
||||
}
|
||||
oscMessages.push(data);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// @ts-ignore
|
||||
outputSocket.onopen = function (event) {
|
||||
@ -20,7 +29,7 @@ outputSocket.onopen = function (event) {
|
||||
outputSocket.send(
|
||||
JSON.stringify({
|
||||
address: "/successful_connexion",
|
||||
args: true,
|
||||
port: 3000, args: {}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user