I’ve been playing around with iPlug2 and the WebUI and I love it so far!
I’ve been able to send messages from the UI to the module using SAMFUI, etc. However, I’m trying to wrap my head around receiving messages and can’t find any documentation or examples.
Here’s what I’ve tried so far:
// ts
export const Elem = () => {
useEffect(() => {
window.SAMFD = (msgTag: number, dataSize: number, msg: Array<number>) => {
// var decodedData = window.atob(msg);
console.log("SAMFD msgTag:" + msgTag + " msg:" + msg);
}
}, [])
return (
<Button
onClick={() => {
if (NODE_ENV === 'production') {
SAMFUI(2, -1, '');
}
}}
>
Ping
</Button>
)
}
// MyModule.cpp
const uint8_t pData = 7;
const uint8_t* pDataPtr = &pData;
bool MyModule::OnMessage(int msgTag, int ctrlTag, int dataSize, const void* pData)
{
DBGMSG("have mesage; tag %d\n", msgTag);
switch (msgTag) {
case 2:
{
MyModule::SendArbitraryMsgFromDelegate(0, 8, pDataPtr);
}
default:
{
DBGMSG("unknown mesage tag %d\n", msgTag);
}
}
return false;
}
However, I get a heap corruption error. What have I done wrong? Thanks!