Skip to content

Commit

Permalink
upgrade delta-listener to v2.0.0. bump v0.7.0-alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jul 5, 2017
1 parent f94f703 commit 780d675
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 48 deletions.
18 changes: 18 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@ NEW
room.listen(...);
console.log( room.data.someDataFromServer );
```

#### `room.listen()` signature has changed.

OLD

```typescript
room.listen("entities/:id/:attribute", "replace", (id, attribute, value) => {
console.log(id, attribute, value);
})
```

NEW

```typescript
room.listen("entities/:id/:attribute", (change) => {
console.log(change.path.id, change.path.attribute, change.value);
})
```
70 changes: 36 additions & 34 deletions dist/colyseus.js

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<script>
var host = window.document.location.host.replace(/:.*/, '');
var client = new Colyseus.Client('ws://' + host + ':8080');
var client = new Colyseus.Client('ws://' + host + ':3553');
var room;

// client.onopen = function() {
Expand All @@ -30,6 +30,25 @@
// console.log("onmessage", data)
// }

function request () {
var http = new XMLHttpRequest();
var params = '{"lorem":"ipsum","name":"binny"}';
http.open("POST", "http://localhost:2657/something", true);

// Send the proper header information along with the request
// http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-type", "application/json");

// Call a function when the state changes.
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}

http.send(params);
}

client.onOpen.add(function() {
console.log("onOpen")

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colyseus.js",
"version": "0.7.0-alpha.3",
"version": "0.7.0-alpha.4",
"description": "Multiplayer Game Client for the Browser",
"keywords": [
"multiplayer",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"clock.js": "^1.1.0",
"delta-listener": "^1.1.0",
"delta-listener": "^2.0.0",
"fossil-delta": "^0.2.5",
"msgpack-lite": "^0.1.20",
"signals.js": "^1.0.0",
Expand Down
16 changes: 8 additions & 8 deletions test/room_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ describe("Room", function() {
let delta = fossilDelta.create(previousState, nextState);

let patchCount = 0;
room.listen("players/:id/:attribute", "replace", (id, attribute, value) => {
room.listen("players/:id/:attribute", (change) => {
patchCount++
assert.equal(id, "one");
assert.equal(attribute, "hp");
assert.equal(value, 40);
assert.equal(change.path.id, "one");
assert.equal(change.path.attribute, "hp");
assert.equal(change.value, 40);
})

room.listen("players/:id/position/:axis", "replace", (id, axis, value) => {
room.listen("players/:id/position/:axis", (change) => {
patchCount++
assert.equal(id, "one");
assert.equal(axis, "y");
assert.equal(value, 100);
assert.equal(change.path.id, "one");
assert.equal(change.path.axis, "y");
assert.equal(change.value, 100);
})

room.patch(delta);
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ delegates@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"

delta-listener@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/delta-listener/-/delta-listener-1.1.0.tgz#a54b8d098321693411e6592282e5b13511bad059"
delta-listener@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/delta-listener/-/delta-listener-2.0.0.tgz#8a8550516eeb631492bea5981a7bdeb33ab254c3"

depd@~1.1.0:
version "1.1.0"
Expand Down

0 comments on commit 780d675

Please sign in to comment.