Guest User

Untitled

a guest
Dec 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. if (message.type === 'utf8') {
  2. console.log(message.utf8Data);
  3. }
  4. if (message.type === 'binary') {
  5. dataStream.write(message.binaryData);
  6. }
  7.  
  8. dataStream.write(message.binaryData);
  9.  
  10. console.log(message.utf8Data);
  11.  
  12. try {
  13. // throw an exception if message type is not utf-8
  14. if (message.type !== 'utf8') {
  15. throw "NotUtf8Encoding"
  16. }
  17. // this will not be reached if the exception is thrown
  18. console.log(message.utf8Data);
  19. } catch(err) { // catch the exception thrown above
  20. if (message.type === 'binary') {
  21. dataStream.write(message.binaryData);
  22. }
  23. /* Do whatever else...*/
  24. }
Add Comment
Please, Sign In to add comment