MCPcopy Index your code
hub / github.com/python-websockets/websockets / sendMoves

Function sendMoves

example/tutorial/step3/main.js:62–82  ·  view source on GitHub ↗
(board, websocket)

Source from the content-addressed store, hash-verified

60}
61
62function sendMoves(board, websocket) {
63 // Don't send moves for a spectator watching a game.
64 const params = new URLSearchParams(window.location.search);
65 if (params.has("watch")) {
66 return;
67 }
68
69 // When clicking a column, send a "play" event for a move in that column.
70 board.addEventListener("click", ({ target }) => {
71 const column = target.dataset.column;
72 // Ignore clicks outside a column.
73 if (column === undefined) {
74 return;
75 }
76 const event = {
77 type: "play",
78 column: parseInt(column, 10),
79 };
80 websocket.send(JSON.stringify(event));
81 });
82}
83
84window.addEventListener("DOMContentLoaded", () => {
85 // Initialize the UI.

Callers 1

main.jsFile · 0.70

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…