Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
colyseus.js
Advanced tools
Colyseus.js - Multiplayer Game Client for the Browser.
JavaScript/TypeScript client for Colyseus Multiplayer Game Server.
The version 0.6.0 is still in beta. Expect some changes before the final release.
import * as Colyseus from "colyseus.js";
var client = new Colyseus.Client('ws://localhost:2657');
var room = client.join("room_name");
room.onJoin.add(function() {
console.log(client.id, "joined", room.name);
});
Here comes the most powerful feature of the client. You can listen to every state update in the server-side, and bind them into client-side functions.
The first parameter is the path of the variable you want to listen to. When you provide placeholders (such as :number
, :id
, :string
) to the path, they will populate the function with the value found on it. See examples below.
Listening to entities being added in the room:
room.listen("entities/:id", "add", (entityId: string, value: any) => {
console.log(`new entity ${entityId}`, value);
});
Listening to entity attributes being replaced:
room.listen("entities/:id/:attribute", "replace", (entityId: string, attribute: string, value: any) => {
console.log(`entity ${entityId} changed attribute ${attribute} to ${value}`);
});
Listening to entities being removed:
room.listen("entities/:id", "remove", (entityId: string) => {
console.log(`entity ${entityId} has been removed`);
});
Room state has been updated:
room.onUpdate.add(function(state) {
console.log(room.name, "has new state:", state)
})
Data coming from server directly to this client:
room.onData.add(function(data) {
console.log(client.id, "received on", room.name, data)
});
Server error occurred:
room.onError.add(function() {
console.log(client.id, "couldn't join", room.name)
});
The client left the room:
room.onLeave.add(function() {
console.log(client.id, "left", room.name)
});
MIT
FAQs
Colyseus Multiplayer SDK for JavaScript/TypeScript
The npm package colyseus.js receives a total of 7,191 weekly downloads. As such, colyseus.js popularity was classified as popular.
We found that colyseus.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.