Loading packages/client/src/lib/canvas.ts +3 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ export class Canvas extends EventEmitter<CanvasEvents> { Network.waitFor("pixelLastPlaced").then( ([time]) => (this.lastPlace = time) ); Network.on("pixel", this.handlePixel); this.draw(); } Loading Loading @@ -110,12 +111,12 @@ export class Canvas extends EventEmitter<CanvasEvents> { }); } handlePixel({ x, y, color }: Pixel) { handlePixel = ({ x, y, color }: Pixel) => { this.pixels[x + "_" + y] = { color, type: "full", }; } }; palleteCtx: IPalleteContext = {}; Pallete = { Loading packages/client/src/lib/network.ts +6 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { AuthSession, ClientConfig, ClientToServerEvents, Pixel, ServerToClientEvents, } from "@sc07-canvas/lib/src/net"; Loading @@ -14,6 +15,7 @@ export interface INetworkEvents { pixels: (data: { available: number }) => void; pixelLastPlaced: (time: number) => void; online: (count: number) => void; pixel: (pixel: Pixel) => void; } type SentEventValue<K extends keyof INetworkEvents> = EventEmitter.ArgumentMap< Loading Loading @@ -60,6 +62,10 @@ class Network extends EventEmitter<INetworkEvents> { this._emit("online", count); }); this.socket.on("pixel", (pixel) => { this.emit("pixel", pixel); }); // this.socket.on("config", (config) => { // Pallete.load(config.pallete); // Canvas.load(config.canvas); Loading Loading
packages/client/src/lib/canvas.ts +3 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ export class Canvas extends EventEmitter<CanvasEvents> { Network.waitFor("pixelLastPlaced").then( ([time]) => (this.lastPlace = time) ); Network.on("pixel", this.handlePixel); this.draw(); } Loading Loading @@ -110,12 +111,12 @@ export class Canvas extends EventEmitter<CanvasEvents> { }); } handlePixel({ x, y, color }: Pixel) { handlePixel = ({ x, y, color }: Pixel) => { this.pixels[x + "_" + y] = { color, type: "full", }; } }; palleteCtx: IPalleteContext = {}; Pallete = { Loading
packages/client/src/lib/network.ts +6 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { AuthSession, ClientConfig, ClientToServerEvents, Pixel, ServerToClientEvents, } from "@sc07-canvas/lib/src/net"; Loading @@ -14,6 +15,7 @@ export interface INetworkEvents { pixels: (data: { available: number }) => void; pixelLastPlaced: (time: number) => void; online: (count: number) => void; pixel: (pixel: Pixel) => void; } type SentEventValue<K extends keyof INetworkEvents> = EventEmitter.ArgumentMap< Loading Loading @@ -60,6 +62,10 @@ class Network extends EventEmitter<INetworkEvents> { this._emit("online", count); }); this.socket.on("pixel", (pixel) => { this.emit("pixel", pixel); }); // this.socket.on("config", (config) => { // Pallete.load(config.pallete); // Canvas.load(config.canvas); Loading