Added updates to the Renderer and Added Machine generate to the connection

This commit is contained in:
duckietm 2024-03-13 11:11:52 +01:00
parent d7d0a48400
commit ce6234fb46
2 changed files with 135 additions and 63 deletions

View File

@ -22,46 +22,48 @@
},
"main": "./index",
"dependencies": {
"@pixi/app": "~6.5.0",
"@pixi/basis": "~6.5.0",
"@pixi/canvas-display": "~6.5.0",
"@pixi/canvas-extract": "~6.5.0",
"@pixi/canvas-renderer": "~6.5.0",
"@pixi/constants": "~6.5.0",
"@pixi/core": "~6.5.0",
"@pixi/display": "~6.5.0",
"@pixi/events": "~6.5.0",
"@pixi/extensions": "~6.5.0",
"@pixi/extract": "~6.5.0",
"@pixi/filter-alpha": "~6.5.0",
"@pixi/filter-color-matrix": "~6.5.0",
"@pixi/graphics": "~6.5.0",
"@pixi/graphics-extras": "~6.5.0",
"@pixi/interaction": "~6.5.0",
"@pixi/loaders": "~6.5.0",
"@pixi/math": "~6.5.0",
"@pixi/math-extras": "~6.5.0",
"@pixi/mixin-cache-as-bitmap": "~6.5.0",
"@pixi/mixin-get-child-by-name": "~6.5.0",
"@pixi/mixin-get-global-position": "~6.5.0",
"@pixi/polyfill": "~6.5.0",
"@pixi/runner": "~6.5.0",
"@pixi/settings": "~6.5.0",
"@pixi/sprite": "~6.5.0",
"@pixi/sprite-tiling": "~6.5.0",
"@pixi/spritesheet": "~6.5.0",
"@pixi/text": "~6.5.0",
"@pixi/ticker": "~6.5.0",
"@pixi/app": "~6.5.10",
"@pixi/basis": "~6.5.10",
"@pixi/canvas-display": "~6.5.10",
"@pixi/canvas-extract": "~6.5.10",
"@pixi/canvas-renderer": "~6.5.10",
"@pixi/constants": "~6.5.10",
"@pixi/core": "~6.5.10",
"@pixi/display": "~6.5.10",
"@pixi/events": "~6.5.10",
"@pixi/extensions": "~6.5.10",
"@pixi/extract": "~6.5.10",
"@pixi/filter-alpha": "~6.5.10",
"@pixi/filter-color-matrix": "~6.5.10",
"@pixi/graphics": "~6.5.10",
"@pixi/graphics-extras": "~6.5.10",
"@pixi/interaction": "~6.5.10",
"@pixi/loaders": "~6.5.10",
"@pixi/math": "~6.5.10",
"@pixi/math-extras": "~6.5.10",
"@pixi/mixin-cache-as-bitmap": "~6.5.10",
"@pixi/mixin-get-child-by-name": "~6.5.10",
"@pixi/mixin-get-global-position": "~6.5.10",
"@pixi/polyfill": "~6.5.10",
"@pixi/runner": "~6.5.10",
"@pixi/settings": "~6.5.10",
"@pixi/sprite": "~6.5.10",
"@pixi/sprite-tiling": "~6.5.10",
"@pixi/spritesheet": "~6.5.10",
"@pixi/text": "~6.5.10",
"@pixi/ticker": "~6.5.10",
"@pixi/tilemap": "^3.2.2",
"@pixi/utils": "~6.5.0",
"@pixi/utils": "~6.5.10",
"clientjs": "^0.2.1",
"gifuct-js": "^2.1.2",
"howler": "^2.2.3",
"pako": "^2.0.4"
"pako": "^2.1.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^10.0.1",
"@types/clientjs": "^0.2.0",
"@types/howler": "^2.2.7",
"@types/pako": "^1.0.3",
"@types/pako": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"eslint": "^8.20.0",

View File

@ -1,9 +1,10 @@
import { IConnection, INitroCommunicationDemo, INitroCommunicationManager, NitroConfiguration, NitroLogger } from '../../api';
import { ClientJS } from 'clientjs';
import { IConnection, INitroCommunicationDemo, INitroCommunicationManager, NitroConfiguration, NitroLogger, } from '../../api';
import { NitroManager } from '../../core';
import { NitroCommunicationDemoEvent, SocketConnectionEvent } from '../../events';
import { NitroCommunicationDemoEvent, SocketConnectionEvent, } from '../../events';
import { GetTickerTime } from '../../pixi-proxy';
import { Nitro } from '../Nitro';
import { AuthenticatedEvent, ClientHelloMessageComposer, ClientPingEvent, InfoRetrieveMessageComposer, PongMessageComposer, SSOTicketMessageComposer } from './messages';
import { AuthenticatedEvent, ClientHelloMessageComposer, ClientPingEvent, InfoRetrieveMessageComposer, PongMessageComposer, SSOTicketMessageComposer, UniqueIDMessageComposer, } from './messages';
export class NitroCommunicationDemo extends NitroManager implements INitroCommunicationDemo
{
@ -15,7 +16,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
private _pongInterval: any;
constructor(communication: INitroCommunicationManager)
{
{
super();
this._communication = communication;
@ -32,11 +33,11 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
protected onInit(): void
{
{
const connection = this._communication.connection;
if(connection)
{
{
connection.addEventListener(SocketConnectionEvent.CONNECTION_OPENED, this.onConnectionOpenedEvent);
connection.addEventListener(SocketConnectionEvent.CONNECTION_CLOSED, this.onConnectionClosedEvent);
connection.addEventListener(SocketConnectionEvent.CONNECTION_ERROR, this.onConnectionErrorEvent);
@ -47,7 +48,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
protected onDispose(): void
{
{
const connection = this._communication.connection;
if(connection)
@ -65,7 +66,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
private onConnectionOpenedEvent(event: Event): void
{
{
const connection = this._communication.connection;
if(!connection) return;
@ -74,7 +75,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ESTABLISHED, connection);
if(NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPonging();
if (NitroConfiguration.getValue<boolean>('system.pong.manually', false)) this.startPonging();
this.startHandshake(connection);
@ -84,7 +85,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
private onConnectionClosedEvent(event: CloseEvent): void
{
{
const connection = this._communication.connection;
if(!connection) return;
@ -95,7 +96,7 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
private onConnectionErrorEvent(event: CloseEvent): void
{
{
const connection = this._communication.connection;
if(!connection) return;
@ -105,12 +106,60 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, connection);
}
private getGpu(): string {
const e = document.createElement('canvas');
let t, s, i, r;
try {
if (
((t = e.getContext('webgl') || e.getContext('experimental-webgl')), (s = t.getExtension('WEBGL_debug_renderer_info')), null === t || null === s))
return '';
} catch (n) {
return '';
}
return ((i = t.getParameter(s.UNMASKED_VENDOR_WEBGL)), (r = t.getParameter(s.UNMASKED_RENDERER_WEBGL)), i + '|' + r);
}
private getMathResult(): string {
let e, t;
(e = '<mathroutines>Error</mathroutines>'), (t = '');
try {
return (
(t ='<mathroutines>' + (Math.exp(10) + 1 / Math.exp(10)) / 2 + '|' + Math.tan(-1e300) + '</mathroutines>'), t);
} catch (s) {
return '<mathroutines>Error</mathroutines>';
}
}
private getCanvas(): any {
const e = document.createElement('canvas'), t = e.getContext('2d'), userAgent = navigator.userAgent, screenInfo = '${window.screen.width}x${window.screen.height}', currentDate = new Date().toString(), s = 'ThiosIsVefwsdcse02wefw83721##@@@_moreStuff! | ${userAgent} | ${screenInfo} | ${currentDate}';
t.textBaseline = 'top';
t.font = "16px 'Arial'";
t.textBaseline = 'alphabetic';
t.rotate(0.05);
t.fillStyle = '#f60';
t.fillRect(125, 1, 62, 20);
t.fillStyle = '#069';
t.fillText(s, 2, 15);
t.fillStyle = 'rgba(102, 200, 0, 0.7)';
t.fillText(s, 4, 17);
t.shadowBlur = 10;
t.shadowColor = 'blue';
t.fillRect(-20, 10, 234, 5);
const i = e.toDataURL();
document.body.appendChild(e);
let r = 0;
if (i.length === 0) return 'nothing!';
for (let n = 0; n < i.length; n++) {
r = (r << 5) - r + i.charCodeAt(n);
r &= r;
}
return r;
}
private tryAuthentication(connection: IConnection): void
{
if(!connection || !this.getSSO())
{
if(!this.getSSO())
{
{
if(!connection || !this.getSSO()) {
if (!this.getSSO()) {
NitroLogger.error('Login without an SSO ticket is not supported');
}
@ -119,18 +168,39 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
return;
}
connection.send(new SSOTicketMessageComposer(this.getSSO(), GetTickerTime()));
// Fingerprinter.
const fp = new ClientJS();
// Browser.
const uniqueId = fp.getCustomFingerprint(
fp.getAvailableResolution(),
fp.getOS(),
fp.getCPU(),
fp.getColorDepth(),
this.getGpu(),
fp.getSilverlightVersion(),
fp.getOSVersion(),
this.getMathResult(),
fp.getCanvasPrint(),
this.getCanvas());
const machineId = uniqueId == null ? 'FAILED' : `IID-${uniqueId}`;
connection.send(
new SSOTicketMessageComposer(this.getSSO(), GetTickerTime())
);
connection.send(new UniqueIDMessageComposer(machineId, '', ''));
}
private onClientPingEvent(event: ClientPingEvent): void
{
{
if(!event || !event.connection) return;
this.sendPong(event.connection);
}
private onAuthenticatedEvent(event: AuthenticatedEvent): void
{
{
if(!event || !event.connection) return;
this.completeHandshake(event.connection);
@ -141,28 +211,28 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
private startHandshake(connection: IConnection): void
{
{
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, connection);
this._handShaking = true;
}
private completeHandshake(connection: IConnection): void
{
{
this.dispatchCommunicationDemoEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKED, connection);
this._handShaking = false;
}
private startPonging(): void
{
{
this.stopPonging();
this._pongInterval = setInterval(this.sendPong, NitroConfiguration.getValue<number>('system.pong.interval.ms', 20000));
this._pongInterval = window.setInterval(this.sendPong, NitroConfiguration.getValue<number>('system.pong.interval.ms', 20000));
}
private stopPonging(): void
{
{
if(!this._pongInterval) return;
clearInterval(this._pongInterval);
@ -171,21 +241,21 @@ export class NitroCommunicationDemo extends NitroManager implements INitroCommun
}
private sendPong(connection: IConnection = null): void
{
connection = ((connection || this._communication.connection) || null);
{
connection = connection || this._communication.connection || null;
if(!connection) return;
connection.send(new PongMessageComposer());
}
private dispatchCommunicationDemoEvent(type: string, connection: IConnection): void
{
private dispatchCommunicationDemoEvent (type: string, connection: IConnection): void
{
Nitro.instance.events.dispatchEvent(new NitroCommunicationDemoEvent(type, connection));
}
private getSSO(): string
{
{
return NitroConfiguration.getValue('sso.ticket', null);
}
}
}