Skip to content

Commit

Permalink
Add HGETALL to the WebSocket HTML demo
Browse files Browse the repository at this point in the history
Quick demo to answer a question asked in GitHub issue #249:
#249
  • Loading branch information
nicolasff committed Oct 5, 2024
1 parent b822b64 commit 5bd37d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/websocket.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ <h3>$TITLE</h3>
</fieldset>
</form>
<form class="pure-form">
<fieldset>
<div class="pure-g">
<div class="pure-u-1-3">&nbsp;</div>
<div class="pure-u-1-3"><input disabled class="pure-u-23-24" type="text" placeholder="key" id="$type-hgetall-key" value="hello" /></div>
<div class="pure-u-1-3"><button disabled type="submit" class="pure-u-23-24 pure-button pure-button-primary" id="$type-btn-hgetall">HGETALL</button></div>
</div>
</fieldset>
</form>
<form class="pure-form">
<fieldset>
<div class="pure-g">
Expand Down Expand Up @@ -190,6 +200,12 @@ <h3>$TITLE</h3>
this.send(serialized);
});

$(`${this.type}-btn-hgetall`).addEventListener('click', event => {
event.preventDefault();
const serialized = this.serializer(['HGETALL', $(`${this.type}-hgetall-key`).value]);
this.send(serialized);
});

$(`${this.type}-btn-pub`).addEventListener('click', event => {
event.preventDefault();
const serialized = this.serializer(['PUBLISH', $(`${this.type}-pub-channel`).value, $(`${this.type}-pub-message`).value]);
Expand Down Expand Up @@ -236,6 +252,8 @@ <h3>$TITLE</h3>
$(`${this.type}-btn-set`).disabled = !connected || this.subscribed;
$(`${this.type}-get-key`).disabled = !connected || this.subscribed;
$(`${this.type}-btn-get`).disabled = !connected || this.subscribed;
$(`${this.type}-btn-hgetall`).disabled = !connected || this.subscribed;
$(`${this.type}-hgetall-key`).disabled = !connected || this.subscribed;
$(`${this.type}-pub-channel`).disabled = !connected || this.subscribed;
$(`${this.type}-pub-message`).disabled = !connected || this.subscribed;
$(`${this.type}-btn-pub`).disabled = !connected || this.subscribed;
Expand Down
2 changes: 1 addition & 1 deletion webdis.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"pool_size": 20,

"daemonize": false,
"websockets": false,
"websockets": true,

"database": 0,

Expand Down

0 comments on commit 5bd37d8

Please sign in to comment.