WebSocketEvent.js 658 B

123456789101112131415161718192021222324252627
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. */
  9. 'use strict';
  10. /**
  11. * Event object passed to the `onopen`, `onclose`, `onmessage`, `onerror`
  12. * callbacks of `WebSocket`.
  13. *
  14. * The `type` property is "open", "close", "message", "error" respectively.
  15. *
  16. * In case of "message", the `data` property contains the incoming data.
  17. */
  18. class WebSocketEvent {
  19. constructor(type, eventInitDict) {
  20. this.type = type.toString();
  21. Object.assign(this, eventInitDict);
  22. }
  23. }
  24. module.exports = WebSocketEvent;