If you're trying to make a webSocket connection from browser Javascript to a server and then send data over that webSocket connection, you will just use the built in webSocket support into the browser. You will just call socket.send()
and the underlying webSocket support will do all the webSocket protocol info for you (including masking).
If you're trying to make a webSocket connection from node.js to some other server, then you would be best served just getting one of the many webSocket libraries for node.js on NPM and using one of those. Those libraries will then do all the webSocket protocol info for you (including masking).
If you're trying to accept an incoming webSocket connection on your own nodejs server, then you would similarly use one of the several webSocket server libraries for node.js and that library would handle all masking for you.
You can only connect a webSocket client to a webSocket server since both ends must use the webSocket connection scheme and then support the webSocket protocol, data framing and security schemes. Unless you're doing this for academic reasons or trying to implement webSockets on a platform that has no generic support for them, it would be rare to implement your own webSocket library. There are variations in the protocol (due to the evolution of the specification and it's a lot of work to properly support and test everything that a full implementation would do).
so i understand that i still need to mask data if I send websockets from a non-ssl website to a ssl server, right?
You appear to be a bit confused. A connection between two endpoints is either SSL or not. You can't have one end of the connection using SSL and the other end not using SSL. A webSocket connection (both ends) can either be run normally or using SSL. The webSocket specification requires that the client mask all data, but that will be done for you automatically by whatever webSocket client library you are using. That is not something you, as a client using the webSocket library, should have to concern yourself with.
A non-SSL webpage (a page that was loaded over regular http not using SSL) could make an SSL webSocket connection to some webSocket server that also supports SSL.