Closed vimlesh1975 closed 1 year ago
Hmm, that's strange! Would you mind sharing a minimum reproducible repo with this issue?
Codesandbox doen't throw warnings. https://codesandbox.io/s/snowy-frost-13cyy7?file=/src/App.js But on my pc it shows like this.
Perhaps the problem is that you're trying to run this in a browser? @mos-connection/connector is a nodejs-only library.
I see two warnings/errors here
1) Can't resolve 'net' in ....
which is because you are trying to import a nodejs library into the browser, and the browser can't make normal tcp connections, so 'net' doesnt exist. This is probably the cause of the failure.
2) Failed to parse source map from ...
which suggests that something to do with we are generating sourcemaps or building the npm package is a bit odd. This shouldn't stop it from functioning at all, as the sourcemaps are for debugging purposes and are not a required part of a npm package.
From The example code provided, Server part in Nodejs working good. I was trying client code in react. Will it work? I imported net in react and showing Error: Can't resolve 'buffer' in 'D:\ggg\node_modules\safe-buffer'. but that i will manage. but will it work? I may be missing some concept of MOS. The example code when try both server and client in different nodejs working fine. I just wanted to send some mos command on a button click from react frontend to nodejs server having mos server code.
My final goal is to make the nodejs server a mos compatible CG.
Ok. Let me put another question here.
I started the server code and in
const { MosConnection, ConnectionConfig, xml2js } = require('@mos-connection/connector')
// more codes
mos.on('rawMessage', (_source, _type, _message) => {
const dd = <?xml version="1.0" encoding="utf-32BE"?><mos xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><mosID>mosID_RCC</mosID><ncsID>NCS_RCC</ncsID><messageID>333</messageID><heartbeat><time>2023-04-25T15:08:36.5534377+05:30</time></heartbeat></mos>
console.log(xml2js(dd))// work ok.
console.log(xml2js(_message)) // error <ref *1> Error: Text data outside of root node.
}
})
When I send MOS message from vb.net client I have to send utf-32BE encoded string to log readable charactors in console.
Now i want to use xml2js.
Problem is xml2js throws error 'Error: Non-whitespace before first tag.'
I think this problem is due to utf-32BE encoding.
Because when i hardcode a xmlstring it parses ok.
ok. I used this and working now. console.log(xml2js(_message.replace(/[^\x20-\x7E]/g, '')))
hmm. It looks like everywhere rawMessage
is emitted we are doing so with proper js strings, the correct side of the unicode conversion. But we are expecting utf16-be
to be the format used.
As you are using utf-32BE
, that mismatch could be the problem? The mos docs say that UCS-2
should be used, which I believe is the same as UTF16
From The example code provided, Server part in Nodejs working good. I was trying client code in react. Will it work? I imported net in react and showing Error: Can't resolve 'buffer' in 'D:\ggg\node_modules\safe-buffer'. but that i will manage. but will it work?
No, the browser won't be able to open the tcp/udp sockets needed for mos 2.8. We don't currently support the newer mos 3 and mos 4 versions which are websockets based and so might be able to work in a browser.
Yes it is utf16-be. Thank you. I was getting string with utf-32BE also. So i thought it is utf-32BE. But Now I did it with utf-16BE and xml2js working fine.
Let me ask some more MOS related questions here. I was searching for CG specific MOS messages. But couldn't find. All messages are normaly for run order. I was looking MOS message for like CG play, CG next, CG stop, CG update, CG list. I have implemented cg play with custom mos message. Can you guide me whre to look and what is general practice?
There isn't any general practice for specific CG commands. Instead you have to define your own ("vendor specific") Mos-objects that work with your CG-client.
Thank you for clarification. The information you gave is a great help for me to pick up a direction. Now , please can i get a reference or link what NRK has defined or implemented?
Sorry, NRK:s graphics solution is not open source, so I can't share how the data structures look like. On a side note though, have you seen the GDD-project? Perhaps it would be helpful to define a Mos-object that is gdd-compatible from the start? (such a discussion is probably better to have over att the GDD-github repo though.)
Thank you for your guidance, Let me study that and come back.
I have imported this npm @mos-connection/connector. in reactjs. when I run i get warning like this. I can see the file is present in dist folder and .js. But it is looking in src folder and .ts.
WARNING in ./node_modules/@mos-connection/model/dist/mosTypes/mosString128.jsModule Warning (from ./node_modules/react-scripts/node_modules/source-map-loader/dist/cjs.js):Failed to parse source map from 'C:\Users\Administrator\Documents\GitHub\tetstprojects\reactmos\node_modules\@mos-connection\model\src\mosTypes\mosString128.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\Administrator\Documents\GitHub\tetstprojects\reactmos\node_modules\@mos-connection\model\src\mosTypes\mosString128.ts'