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

Function sendMoves

example/tutorial/step2/main.js:52–72  ·  view source on GitHub ↗
(board, websocket)

Source from the content-addressed store, hash-verified

50}
51
52function sendMoves(board, websocket) {
53 // Don't send moves for a spectator watching a game.
54 const params = new URLSearchParams(window.location.search);
55 if (params.has("watch")) {
56 return;
57 }
58
59 // When clicking a column, send a "play" event for a move in that column.
60 board.addEventListener("click", ({ target }) => {
61 const column = target.dataset.column;
62 // Ignore clicks outside a column.
63 if (column === undefined) {
64 return;
65 }
66 const event = {
67 type: "play",
68 column: parseInt(column, 10),
69 };
70 websocket.send(JSON.stringify(event));
71 });
72}
73
74window.addEventListener("DOMContentLoaded", () => {
75 // 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…