micnic / simples

Simple Web Framework for Node.JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReferenceError: wsParser is not defined

aroraayush opened this issue · comments

I want to get data in chunks and then join them via Web Socket. I got this page when trying to look for solution

`
var parser = new wsParser(0, false);

socket.pipe(parser);

parse.on('error', function (error) {
// handle the error
}.on('frame', function (frame) {
// handle the frame

/*
  The structure of a frame:
  {
    data: buffer,
    fin: boolean,
    length: int,
    masked: boolean,
    opcode: int
  }
*/

});
`

But, now that I have created a simples server and used wsParser, I am getting the error
ReferenceError: wsParser is not defined

The WebSocket parser included in simples is supposed to work only with the code of the framework, it seems that you are trying to use it outside of the framework, your error seems to be because of nor requiring the wsParser before running the code, first of all I recommend you to use the code that is in the github repo (not npm) as it is updated and has better performance.