solved frame order buf on writeEnd and cleaned up code in WebSocket