You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

simple-room-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-room-client - npm Package Compare versions

Comparing version

to
3.0.0

6

lib/world.d.ts

@@ -0,1 +1,4 @@

type ListenOptions = {
encoded?: boolean;
};
export declare class WorldClass {

@@ -37,5 +40,6 @@ socket: any;

*/
listen(socket: any, transformData?: Function): this;
listen(socket: any, options?: ListenOptions): this;
reset(): void;
}
export declare const World: WorldClass;
export {};

15

lib/world.js

@@ -53,3 +53,5 @@ import msgpack from 'msgpack-lite';

*/
listen(socket, transformData) {
listen(socket, options = {}) {
if (options.encoded === undefined)
options.encoded = true;
this.socket = socket;

@@ -59,6 +61,11 @@ this.socket.on('uid', (response) => {

});
this.socket.on('connect', () => {
this.obs$.next({});
});
this.socket.on('w', (response) => {
const bufView = new Uint8Array(response);
const decode = msgpack.decode(bufView);
const [roomId, time, data] = decode;
if (options.encoded) {
const bufView = new Uint8Array(response);
response = msgpack.decode(bufView);
}
const [roomId, time, data] = response;
const lastRoomId = this.obs$.value.roomId;

@@ -65,0 +72,0 @@ let mergeData = {};

{
"name": "simple-room-client",
"version": "2.0.6",
"version": "3.0.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/simple-room-client.umd.cjs",

@@ -8,2 +8,6 @@ import msgpack from 'msgpack-lite'

type ListenOptions = {
encoded?: boolean
}
export class WorldClass {

@@ -60,3 +64,5 @@ socket: any

*/
listen(socket, transformData?: Function) {
listen(socket, options: ListenOptions = {}) {
if (options.encoded === undefined) options.encoded = true
this.socket = socket

@@ -66,6 +72,16 @@ this.socket.on('uid', (response) => {

})
this.socket.on('connect', () => {
this.obs$.next({})
})
this.socket.on('w', (response) => {
const bufView = new Uint8Array(response)
const decode = msgpack.decode(bufView)
const [roomId, time, data] = decode
if (options.encoded) {
const bufView = new Uint8Array(response)
response = msgpack.decode(bufView)
}
const [roomId, time, data] = response
const lastRoomId = this.obs$.value.roomId

@@ -94,3 +110,3 @@ let mergeData: any = {}

}
if (data.users) {

@@ -97,0 +113,0 @@ mergeData.users = this.users.detectChanges(mergeData.users)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet