Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (message.type === 'utf8') {
- console.log(message.utf8Data);
- }
- if (message.type === 'binary') {
- dataStream.write(message.binaryData);
- }
- dataStream.write(message.binaryData);
- console.log(message.utf8Data);
- try {
- // throw an exception if message type is not utf-8
- if (message.type !== 'utf8') {
- throw "NotUtf8Encoding"
- }
- // this will not be reached if the exception is thrown
- console.log(message.utf8Data);
- } catch(err) { // catch the exception thrown above
- if (message.type === 'binary') {
- dataStream.write(message.binaryData);
- }
- /* Do whatever else...*/
- }
Add Comment
Please, Sign In to add comment