Results 1 to 2 of 2

Thread: Can i process a message before socket.emit method?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2021
    Posts
    5

    Can i process a message before socket.emit method?

    When it comes to network programming, I often get confused. I'm working on a chat app that broadcasts the message. But here, my client wants to encrypt the message before broadcasting the message just to enhance security,

    For encryption, i want to include a 3-4 lines javascript code for binary translation before the socket.emit method in my node.js app. is there a way to perform such operation?

  2. #2

    Thread Starter
    New Member
    Join Date
    Feb 2021
    Posts
    5

    Re: Can i process a message before socket.emit method?

    Quote Originally Posted by bryanzspittle View Post
    When it comes to network programming, I often get confused. I'm working on a chat app that broadcasts the message. But here, my client wants to encrypt the message before broadcasting the message just to enhance security,

    For encryption, i want to include a 3-4 lines javascript code for binary translation before the socket.emit method in my node.js app. is there a way to perform such operation?
    Okay, after researching for a few day, I have found the solution here.

    Inside of the socket.on method, I can write any code I want and if the logic is complicated then i can easily use state-management frameworks like Vuex, redux.

    here is the code,

    socket.on(convertmessage, 'data') => {
    binarylogic, scraped from this page
    the data will be stored inside data variable
    var data = binary processed;
    socket.emit(binary, 'data');
    }
    here, in this code socket.on will listen to the broadcasts and get the message string. Once, it gets the message string, it will convert that into equivalent binary and with the help of socket.emit method, the binary translation will be sent to the users.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width