Skip to content

Commit

Permalink
Merge pull request #99 from project-slippi/feature/broadcast
Browse files Browse the repository at this point in the history
Add Broadcasting
  • Loading branch information
NikhilNarayana authored Nov 26, 2020
2 parents 15cdbca + 3115625 commit aee6e3d
Show file tree
Hide file tree
Showing 55 changed files with 3,646 additions and 561 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FIREBASE_API_KEY=example
FIREBASE_AUTH_DOMAIN=example
FIREBASE_DATABASE_URL=example
FIREBASE_PROJECT_ID=example
FIREBASE_STORAGE_BUCKET=example
FIREBASE_MESSAGING_SENDER_ID=example
FIREBASE_APP_ID=example
FIREBASE_MEASUREMENT_ID=example

SLIPPI_WS_SERVER=ws://localhost:9898/
100 changes: 100 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release Builds

on:
push:
paths-ignore:
- '**.md'

jobs:
package:
name: Build and package on node ${{ matrix.node-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [10.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
include:
- os: windows-latest
playback_image: windows64-playback
playback_dolphin_path: app/dolphin-dev/windows/
- os: ubuntu-latest
playback_image: linux-playback
playback_dolphin_path: app/dolphin-dev/linux/
- os: macOS-latest
playback_image: macOS-playback
playback_dolphin_path: app/dolphin-dev/osx/
steps:
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Checkout
uses: actions/[email protected]
- name: Fetch Git Tags
if: success()
shell: bash
run: |
git fetch --prune --unshallow
echo "GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@v1
id: cache
with:
path: node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Load macOS signing certificates and secrets
if: matrix.os == 'macOS-latest' && env.CERTIFICATE_MACOS_PASSWORD != null
run: |
chmod +x build/load-macos-certs-ci.sh && ./build/load-macos-certs-ci.sh
mkdir -p ~/private_keys/
echo '${{ secrets.APPLE_CONNECT_API_KEY }}' > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
echo "CSC_LINK=${{ secrets.CERTIFICATE_MACOS_APPLICATION }}" >> $GITHUB_ENV
echo "CSC_KEY_PASSWORD=${{ secrets.CERTIFICATE_MACOS_PASSWORD }}" >> $GITHUB_ENV
echo "APPLE_API_KEY=${{ secrets.APPLE_API_KEY_ID }}" >> $GITHUB_ENV
echo "APPLE_ISSUER_ID=${{ secrets.APPLE_ISSUER_ID }}" >> $GITHUB_ENV
echo "APPLE_TEAM_PROVIDER_ID=${{ secrets.APPLE_TEAM_PROVIDER_ID }}" >> $GITHUB_ENV
env:
CERTIFICATE_MACOS_APPLICATION: ${{ secrets.CERTIFICATE_MACOS_APPLICATION }}
CERTIFICATE_MACOS_PASSWORD: ${{ secrets.CERTIFICATE_MACOS_PASSWORD }}
- name: Install dependencies
run: |
yarn install
- name: Download playback artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: pr-build.yml
branch: slippi
name: ${{ matrix.playback_image }}
path: ${{ matrix.playback_dolphin_path }}
repo: project-slippi/Ishiiruka
- name: Unzip
shell: bash
working-directory: ${{ matrix.playback_dolphin_path }}
run: |
unzip *
rm *.zip
- name: Package
shell: bash
working-directory: ${{ github.workspace }}
run: |
echo ${{ secrets.ENVFILE }} > .env
yarn package
mkdir artifact
cp ./release/Slippi* ./artifact
cp ./release/*.yml ./artifact
env:
USE_HARD_LINKS: false
- name: Publish
if: success()
uses: actions/upload-artifact@v2-preview
with:
name: ${{ matrix.os }}
path: './artifact/'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ main.js.map
npm-debug.log.*

dolphin/

.env
55 changes: 55 additions & 0 deletions app/actions/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { auth } from 'firebase';

export const SET_AUTH_USER = 'SET_AUTH_USER';
export const SET_AUTH_LOADING = 'SET_AUTH_LOADING';
export const SET_AUTH_ERROR = 'SET_AUTH_ERROR';

export function setAuthUser(user) {
return async dispatch => {
dispatch({
type: SET_AUTH_USER,
user: user,
});
};
}

export function login(email, password, callback) {
return async (dispatch) => {
// Set loading state
dispatch({
type: SET_AUTH_LOADING,
loading: true,
});

// Clear any existing errors
dispatch({
type: SET_AUTH_ERROR,
error: null,
});

try {
const user = await auth().signInWithEmailAndPassword(email, password);
if (user && callback) {
callback();
}
} catch (err) {
console.error(err);
dispatch({
type: SET_AUTH_ERROR,
error: err.message,
});
}

// Clear loading state
dispatch({
type: SET_AUTH_LOADING,
loading: false,
});
};
}

export function logout() {
return async () => {
await auth().signOut();
};
}
75 changes: 75 additions & 0 deletions app/actions/broadcast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { BroadcastManager } from '../domain/BroadcastManager';
import { SpectateManager } from '../domain/SpectateManager';

export const SET_DOLPHIN_STATUS = 'SET_DOLPHIN_STATUS';
export const SET_SLIPPI_STATUS = 'SET_SLIPPI_STATUS';
export const UPDATE_VIEWABLE_BROADCASTS = 'UPDATE_VIEWABLE_BROADCASTS';

const broadcastManager = new BroadcastManager();
const spectateManager = new SpectateManager();

export function setDolphinStatus(status) {
return async (dispatch) => {
dispatch({
type: SET_DOLPHIN_STATUS,
status: status,
});
};
}

export function setSlippiStatus(status) {
return async (dispatch) => {
dispatch({
type: SET_SLIPPI_STATUS,
status: status,
});
};
}

export function updateViewableBroadcasts(broadcasts) {
return async (dispatch) => {
dispatch({
type: UPDATE_VIEWABLE_BROADCASTS,
broadcasts: broadcasts,
});
};
}

export function startBroadcast(target) {
return async () => {
await broadcastManager.start(target);
};
}

export function stopBroadcast() {
return async () => {
broadcastManager.stop();
};
}

export function refreshBroadcasts() {
return async () => {
try {
await spectateManager.connect();
spectateManager.refreshBroadcasts();
} catch {
// Do nothing
}
};
}

export function watchBroadcast(broadcastId) {
return async () => {
spectateManager.watchBroadcast(broadcastId);
};
}

export function initSpectate() {
return async () => {
try {
await spectateManager.connect();
} catch {
// Do nothing
}
};
}
4 changes: 3 additions & 1 deletion app/actions/game.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash';
import SlippiGame from '@slippi/slippi-js';
import log from 'electron-log';

export const GAME_LOAD_START = 'GAME_LOAD_START'
export const GAME_LOAD_COMPLETE = 'GAME_LOAD_COMPLETE';
Expand Down Expand Up @@ -41,7 +42,8 @@ async function loadGame(gameOrPath) {
settings = gameToLoad.getSettings();
stats = gameToLoad.getStats();
gameToLoad.getMetadata();
} catch {
} catch (err) {
log.error(`Error loading replay file\n`, err);
return null;
}

Expand Down
Loading

0 comments on commit aee6e3d

Please sign in to comment.