Skip to content

Commit 31317f9

Browse files
committed
up lint and deduplicate
1 parent 4236897 commit 31317f9

6 files changed

Lines changed: 53 additions & 89 deletions

File tree

js/network/socketiyo-client/examples/exampleClient.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ useDefaultLogging({ socketiyoConnection });
2020

2121
socketiyoConnection.on(DEFAULT_CHANNEL, (x) => {
2222
console.log(x);
23-
document.body.textContent += x;
2423
});
2524

2625
socketiyoConnection.on(`game/end`, (x) => {
2726
console.log(`game/end ${x}`);
28-
document.body.textContent += x;
2927
});
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,2 @@
11
import "./addWsToNode.js";
2-
import {
3-
createConnection,
4-
CONNECT,
5-
DISCONNECT,
6-
ERROR,
7-
DEFAULT_CHANNEL
8-
} from "../source/socketiyo-client.js";
9-
import { reconnectDelay, randomReconnectDelay, autoReconnect } from "../source/defaultOptions.js";
10-
import { useDefaultLogging } from "../source/defaultLogging.js";
11-
12-
13-
const socketiyoConnection = createConnection({
14-
url: `ws://localhost:8080/socketiyo`,
15-
reconnectDelay,
16-
randomReconnectDelay,
17-
autoReconnect,
18-
});
19-
20-
useDefaultLogging({ socketiyoConnection });
21-
22-
socketiyoConnection.on(DEFAULT_CHANNEL, (x) => {
23-
console.log(x);
24-
});
25-
26-
socketiyoConnection.on(`game/end`, (x) => {
27-
console.log(`game/end ${x}`);
28-
});
2+
import "./exampleClient.js";

js/network/socketiyo-client/examples/package-lock.json

Lines changed: 37 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "examples",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"type": "module",
55
"scripts": {
66
"serve": "serve ../.",
7-
"node-client": "node --experimental-modules exampleNodeClient.js"
7+
"node-client": "node exampleNodeClient.js"
88
},
9-
"private": true,
109
"devDependencies": {
11-
"serve": "^11.1.0"
12-
},
13-
"dependencies": {
14-
"majo-ubjson": "^1.1.0",
15-
"ws": "^7.1.2"
16-
}
10+
"serve": "^11.3.2"
11+
},
12+
"dependencies": {
13+
"majo-ubjson": "^1.1.0",
14+
"ws": "^7.1.2"
15+
},
16+
"private": true
1717
}

js/network/socketiyo-client/source/defaultLogging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
const useDefaultLogging = ({ socketiyoConnection, logger = console }) => {
1111
socketiyoConnection.on(RECONNECTING, () => {
12-
logger.log(`reconnecting`)
12+
logger.log(`reconnecting`);
1313
});
1414

1515
socketiyoConnection.on(DISCONNECT, x => {

js/network/socketiyo-client/source/socketiyo-client.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export {
44
CONNECT,
55
DISCONNECT,
66
ERROR,
7-
DEFAULT_CHANNEL
7+
DEFAULT_CHANNEL,
88
};
99

1010
import {
@@ -17,7 +17,7 @@ import {
1717
defaultUnpackData,
1818
SUBSCRIBE_CHANNEL_ACTION,
1919
UNSUBSCRIBE_CHANNEL_ACTION,
20-
DEFAULT_CHANNEL
20+
DEFAULT_CHANNEL,
2121
} from "../node_modules/socketiyo-shared/source/socketiyo-shared.js";
2222

2323
const RECONNECTING = Symbol();
@@ -70,7 +70,7 @@ const createConnection = (options) => {
7070
if (connection.readyState === WebSocket.OPEN) {
7171
connection.send(x);
7272
} else {
73-
delayedUntilOpen.push(x)
73+
delayedUntilOpen.push(x);
7474
}
7575
};
7676
const sendOrDrop = (x) => {
@@ -93,7 +93,7 @@ const createConnection = (options) => {
9393
}
9494
sendOrDrop(packData({
9595
channel: eventName,
96-
action: SUBSCRIBE_CHANNEL_ACTION
96+
action: SUBSCRIBE_CHANNEL_ACTION,
9797
}));
9898
});
9999
facade.on(onLastUnsubscribeString, eventName => {
@@ -102,7 +102,7 @@ const createConnection = (options) => {
102102
}
103103
sendOrDrop(packData({
104104
channel: eventName,
105-
action: UNSUBSCRIBE_CHANNEL_ACTION
105+
action: UNSUBSCRIBE_CHANNEL_ACTION,
106106
}));
107107
});
108108
reconnect();

0 commit comments

Comments
 (0)