Skip to content

Commit

Permalink
Merge pull request #220 from project-slippi/fix/mirroring
Browse files Browse the repository at this point in the history
fix: mirroring by using latest slippi-js
  • Loading branch information
NikhilNarayana authored Aug 16, 2021
2 parents 9fb74c4 + f56a391 commit 7fb34ba
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.58",
"@slippi/slippi-js": "^6.1.1",
"@slippi/slippi-js": "6.1.2",
"adm-zip": "^0.5.1",
"compare-func": "^2.0.0",
"cross-fetch": "^3.0.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
diff --git a/node_modules/@slippi/slippi-js/dist/index.es.js b/node_modules/@slippi/slippi-js/dist/index.es.js
index ba1a67e..5bdd7cd 100644
index 2710ec9..9ac9b90 100644
--- a/node_modules/@slippi/slippi-js/dist/index.es.js
+++ b/node_modules/@slippi/slippi-js/dist/index.es.js
@@ -4,6 +4,7 @@ import fs from 'fs';
import moment from 'moment';
@@ -5,6 +5,7 @@ import moment from 'moment';
import { Writable } from 'stream';
import { decode, encode } from '@shelacek/ubjson';
import net from 'net';
+import enet from 'enet';
import inject from 'reconnect-core';
import { decode, encode } from '@shelacek/ubjson';
import iconv from 'iconv-lite';
@@ -2081,7 +2082,6 @@ class DolphinConnection extends EventEmitter {
import path from 'path';
@@ -2085,7 +2086,6 @@ class DolphinConnection extends EventEmitter {
console.log(`Connecting to: ${ip}:${port}`);
this.ipAddress = ip;
this.port = port;
Expand Down
4 changes: 2 additions & 2 deletions src/console/mirrorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class MirrorManager extends EventEmitter {
});
});
this.emit(MirrorEvent.LOG, config.port);
connection.connect(config.ipAddress, config.port ?? Ports.DEFAULT);
connection.connect(config.ipAddress, config.port ?? Ports.DEFAULT, config.isRealtime);

let autoSwitcher: AutoSwitcher | null = null;
if (config.autoSwitcherSettings) {
Expand Down Expand Up @@ -219,7 +219,7 @@ export class MirrorManager extends EventEmitter {
}

private async _playFile(filePath: string, playbackId: string) {
return this.emit(MirrorEvent.NEW_FILE, playbackId, filePath, this.mirrors[playbackId].isRealTimeMode);
return this.emit(MirrorEvent.NEW_FILE, playbackId, filePath, this.mirrors[playbackId].isRealtime);
}

public async handleClosedDolphin(playbackId: string) {
Expand Down
10 changes: 5 additions & 5 deletions src/console/mirrorWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface Methods {
dolphinClosed(playbackId: string): Promise<void>;
getLogObservable(): Observable<string>;
getErrorObservable(): Observable<Error | string>;
getMirrorDetailsObservable(): Observable<{ playbackId: string; filePath: string; isRealTimeMode: boolean }>;
getMirrorDetailsObservable(): Observable<{ playbackId: string; filePath: string; isRealtime: boolean }>;
getMirrorStatusObservable(): Observable<{ ip: string; info: Partial<ConsoleMirrorStatusUpdate> }>;
}

Expand All @@ -27,7 +27,7 @@ const mirrorManager = new MirrorManager();

const logSubject = new Subject<string>();
const errorSubject = new Subject<Error | string>();
const mirrorDetailsSubject = new Subject<{ playbackId: string; filePath: string; isRealTimeMode: boolean }>();
const mirrorDetailsSubject = new Subject<{ playbackId: string; filePath: string; isRealtime: boolean }>();
const mirrorStatusSubject = new Subject<{ ip: string; info: Partial<ConsoleMirrorStatusUpdate> }>();

// Forward the events to the renderer
Expand All @@ -39,8 +39,8 @@ mirrorManager.on(MirrorEvent.ERROR, async (error: Error | string) => {
errorSubject.next(error);
});

mirrorManager.on(MirrorEvent.NEW_FILE, async (playbackId: string, filePath: string, isRealTimeMode: boolean) => {
mirrorDetailsSubject.next({ playbackId, filePath, isRealTimeMode });
mirrorManager.on(MirrorEvent.NEW_FILE, async (playbackId: string, filePath: string, isRealtime: boolean) => {
mirrorDetailsSubject.next({ playbackId, filePath, isRealtime });
});

mirrorManager.on(
Expand Down Expand Up @@ -72,7 +72,7 @@ const methods: WorkerSpec = {
getErrorObservable(): Observable<Error | string> {
return Observable.from(errorSubject);
},
getMirrorDetailsObservable(): Observable<{ playbackId: string; filePath: string; isRealTimeMode: boolean }> {
getMirrorDetailsObservable(): Observable<{ playbackId: string; filePath: string; isRealtime: boolean }> {
return Observable.from(mirrorDetailsSubject);
},
getMirrorStatusObservable(): Observable<{ ip: string; info: Partial<ConsoleMirrorStatusUpdate> }> {
Expand Down
2 changes: 1 addition & 1 deletion src/console/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface MirrorConfig {
ipAddress: string;
port: number;
folderPath: string;
isRealTimeMode: boolean;
isRealtime: boolean;
enableRelay: boolean;
autoSwitcherSettings?: AutoSwitcherSettings;
}
Expand Down
4 changes: 2 additions & 2 deletions src/console/workerInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const mirrorWorker: Promise<Thread & MirrorWorkerMethods> = new Promise((
worker.getErrorObservable().subscribe((errorMessage) => {
mirrorLog.error(errorMessage);
});
worker.getMirrorDetailsObservable().subscribe(({ playbackId, filePath, isRealTimeMode }) => {
worker.getMirrorDetailsObservable().subscribe(({ playbackId, filePath, isRealtime }) => {
const replayComm: ReplayCommunication = {
mode: "mirror",
isRealTimeMode: isRealTimeMode,
isRealtime: isRealtime,
replay: filePath,
};
dolphinManager.launchPlaybackDolphin(playbackId, replayComm).catch(mirrorLog.error);
Expand Down
2 changes: 1 addition & 1 deletion src/dolphin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface ReplayCommunication {
endFrame?: number; // when to stop watching the replay
commandId?: string; // random string, doesn't really matter
outputOverlayFiles?: boolean; // outputs gameStartAt and gameStation to text files (only works in queue mode)
isRealTimeMode?: boolean; // default true; keeps dolphin fairly close to real time (about 2-3 frames); only relevant in mirror mode
isRealtime?: boolean; // default true; keeps dolphin fairly close to real time (about 2-3 frames); only relevant in mirror mode
shouldResync?: boolean; // default true; disables the resync functionality
rollbackDisplayMethod?: "off" | "normal" | "visible"; // default off; normal shows like a player experienced it, visible shows ALL frames (normal and rollback)
queue?: ReplayQueueItem[];
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/containers/Console/AddConnectionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const AddConnectionDialog: React.FC<AddConnectionDialogProps> = ({
};
const defaultValues: Partial<StoredConnection> = merge(
{
isRealTimeMode: false,
isRealtime: false,
folderPath: spectateFolder,
port: Ports.DEFAULT,
enableRelay: false,
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/containers/Console/AddConnectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type FormValues = {
ipAddress: string;
port: number;
folderPath: string;
isRealTimeMode: boolean;
isRealtime: boolean;
enableAutoSwitcher: boolean;
obsIP?: string;
obsSourceName?: string;
Expand All @@ -44,7 +44,7 @@ export const AddConnectionForm: React.FC<AddConnectionFormProps> = ({ defaultVal
formState: { errors },
} = useForm<FormValues>({ defaultValues });
const folderPath = watch("folderPath");
const isRealTimeMode = watch("isRealTimeMode");
const isRealtime = watch("isRealtime");
const enableAutoSwitcher = watch("enableAutoSwitcher");
const obsPassword = watch("obsPassword");
const obsSourceName = watch("obsSourceName");
Expand Down Expand Up @@ -87,8 +87,8 @@ export const AddConnectionForm: React.FC<AddConnectionFormProps> = ({ defaultVal
</section>
<section>
<Toggle
value={Boolean(isRealTimeMode)}
onChange={(checked) => setValue("isRealTimeMode", checked)}
value={Boolean(isRealtime)}
onChange={(checked) => setValue("isRealtime", checked)}
label="Enable Real-time Mode"
description="Prevents delay from accumulating when mirroring. Keep this off unless both the Wii and computer are on a wired LAN connection."
/>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/lib/consoleConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const connectToConsole = async (conn: StoredConnection) => {
ipAddress: conn.ipAddress,
port: conn.port ?? Ports.DEFAULT,
folderPath: conn.folderPath,
isRealTimeMode: conn.isRealTimeMode,
isRealtime: conn.isRealtime,
enableRelay: conn.enableRelay,
};

Expand Down
2 changes: 1 addition & 1 deletion src/settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface StoredConnection {
id: number;
ipAddress: string;
folderPath: string;
isRealTimeMode: boolean;
isRealtime: boolean;
port?: number;
consoleNick?: string;
enableAutoSwitcher: boolean;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2332,10 +2332,10 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==

"@slippi/slippi-js@^6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-6.1.1.tgz#b99e520d2bd71ffd7f99099362afc01b638c2a26"
integrity sha512-14Ob9GB4j+PGHAr6OMLHDOKxD9W7Z8ll6YxgSQD01tI6yJ10G2LRtL0rjuUKG2tcC+rcuqrkJ8H81UUM3d7uZg==
"@slippi/[email protected].2":
version "6.1.2"
resolved "https://registry.yarnpkg.com/@slippi/slippi-js/-/slippi-js-6.1.2.tgz#6cedd18d54ead123a9ed40f1f2e514b7bbb4d770"
integrity sha512-cZEWKJWRB61ZZEUBIsRi1TPcmWFIU+Z9fQd650jyxFJAS9j0xWWAZypd5TM9TfhaMyOU73XsQ5DLoeH7BPumXw==
dependencies:
"@shelacek/ubjson" "^1.0.1"
enet "^0.2.9"
Expand Down

0 comments on commit 7fb34ba

Please sign in to comment.