What is the use of dispatchEvent() in WebSocket?

I notice WebSocket extends EventTarget and EventTarget.dispatchEvent()sends an Event to the object“. But it is not clear from that MDN document who the object is.

I had thought maybe that object was the receiver on the WebSocket server side and dispatchEvent() is another way to send a message to the ws server like WebSocket.send()

So I did the following test in the browser console, using https://github.com/websockets/ws for ws server.

const ws = new WebSocket('ws://localhost:3000');

//instead of using ws.send('hello world'); I use dispatchEvent here

ws.addEventListener('open', (evt) => {
      let event = new MessageEvent('message', {
          data: "hello world",
          lastEventId: '101'
       });
  ws.dispatchEvent(event);
});

ws.addEventListener('message', (event) => {
    console.log('Message from server ', event.data);
});

But as it turns out the console immediately prints out “Message from server hello world” while ws server didn’t get that event.

So what is the use of dispatchEvent() in WebSocket ?