Last active
          November 21, 2022 20:46 
        
      - 
      
- 
        Save yakovenkodenis/908e3b8b8ad2b44725578edb0eee2e6b to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | parseFrame(buffer) { | |
| // ... first byte processing ... | |
| const secondByte = buffer.readUInt8(1); | |
| let offset = 2; | |
| let payloadLength = secondByte & 0b01111111; // get last 7 bits of a second byte | |
| if (payloadLength === 126) { | |
| offset += 2; | |
| } else if (payloadLength === 127) { | |
| offset += 8; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment