Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/editor-api/realtime/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class RealtimeAsset extends Events {
}

_onOp(ops: any, local: boolean) {
if (local) {
if (local || !this._loaded) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/editor/alerts/alert-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ editor.once('load', () => {

editor.on('viewport:error', (err) => {
viewportError = true;
log.error(err);
console.error(err);
console.trace();
content.innerHTML = 'Failed creating WebGL Context.<br />Please check <a href="http://webglreport.com/" target="_blank">WebGL Report</a> and report to <a href="http://forum.playcanvas.com/" target="_blank">Forum</a>.';
overlay.hidden = false;
Expand Down
2 changes: 1 addition & 1 deletion src/editor/assets/assets-rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ editor.once('load', () => {
const changeName = function (assetId: string | number, assetName: string) {
editor.api.globals.rest.assets.assetUpdate(assetId, { name: assetName })
.on('error', (err, data) => {
log.error`rename error: ${err} ${data}`;
console.warn(`rename error: ${err} ${data}`);
editor.call('status:error', `Couldn't update the name: ${data}`);
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/editor/entities/entities-treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ class EntitiesTreeView extends TreeView {
if (child) {
treeViewItem.append(this._onAddEntity(child));
} else {
log.error`cannot find child entity ${childId} of parent ${entity.get('name')} (${resourceId})`;
console.warn(`cannot find child entity ${childId} of parent ${entity.get('name')} (${resourceId})`);
editor.call('status:error', `Cannot find child entity ${childId} of parent "${entity.get('name')}" (${resourceId})`);
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/editor/relay/relay-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class RelayServer extends Events {

private _rooms: Record<string, Set<number>>;

private _pendingRooms: Set<string>;

private _userId: number | null;

private socket: WebSocket;
Expand All @@ -54,6 +56,7 @@ class RelayServer extends Events {
this._pingTimeout = null;
this._pongTimeout = null;
this._rooms = {};
this._pendingRooms = new Set();
this._userId = null;

this.on('welcome', (data) => {
Expand Down Expand Up @@ -150,6 +153,7 @@ class RelayServer extends Events {
});
}
this._rooms = {};
this._pendingRooms.clear();

this.emit('disconnect');

Expand Down Expand Up @@ -194,6 +198,8 @@ class RelayServer extends Events {
}

_handleRoomJoin(msg: { t: string; name: string; users?: number[]; userId?: number }) {
this._pendingRooms.delete(msg.name);

if (msg.users) {
this._rooms[msg.name] = new Set(msg.users);
} else if (msg.userId) {
Expand Down Expand Up @@ -281,7 +287,7 @@ class RelayServer extends Events {
* @param msg - The message data
*/
send(msg: string | object) {
if (!this._connected) {
if (!this._connected || this.socket.readyState !== WebSocket.OPEN) {
return;
}

Expand Down Expand Up @@ -319,6 +325,11 @@ class RelayServer extends Events {
* @param authentication - The authentication handling of the room.
*/
joinRoom(name: string, authentication: RoomAuthentication) {
if (this._rooms[name] || this._pendingRooms.has(name)) {
return;
}

this._pendingRooms.add(name);
this.send({
t: 'room:join',
name: name,
Expand Down