From 9201b5318bcbaeefa7f86f91665d20e7c64bbae4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 9 Jul 2018 21:15:49 +0900 Subject: [PATCH] Refactoring --- .../scripts/streaming/{ => games}/reversi-game.ts | 6 +++--- .../common/scripts/streaming/{ => games}/reversi.ts | 8 ++++---- src/client/app/mios.ts | 2 +- src/server/api/stream/{ => games}/reversi-game.ts | 10 +++++----- src/server/api/stream/{ => games}/reversi.ts | 4 ++-- src/server/api/streaming.ts | 8 ++++---- 6 files changed, 19 insertions(+), 19 deletions(-) rename src/client/app/common/scripts/streaming/{ => games}/reversi-game.ts (57%) rename src/client/app/common/scripts/streaming/{ => games}/reversi.ts (74%) rename src/server/api/stream/{ => games}/reversi-game.ts (96%) rename src/server/api/stream/{ => games}/reversi.ts (86%) diff --git a/src/client/app/common/scripts/streaming/reversi-game.ts b/src/client/app/common/scripts/streaming/games/reversi-game.ts similarity index 57% rename from src/client/app/common/scripts/streaming/reversi-game.ts rename to src/client/app/common/scripts/streaming/games/reversi-game.ts index 5638b3013f..2fe7dd3b07 100644 --- a/src/client/app/common/scripts/streaming/reversi-game.ts +++ b/src/client/app/common/scripts/streaming/games/reversi-game.ts @@ -1,9 +1,9 @@ -import Stream from './stream'; -import MiOS from '../../../mios'; +import Stream from '../stream'; +import MiOS from '../../../../mios'; export class ReversiGameStream extends Stream { constructor(os: MiOS, me, game) { - super(os, 'reversi-game', { + super(os, 'games/reversi-game', { i: me ? me.token : null, game: game.id }); diff --git a/src/client/app/common/scripts/streaming/reversi.ts b/src/client/app/common/scripts/streaming/games/reversi.ts similarity index 74% rename from src/client/app/common/scripts/streaming/reversi.ts rename to src/client/app/common/scripts/streaming/games/reversi.ts index 2e4395f0f1..1fef93e4bf 100644 --- a/src/client/app/common/scripts/streaming/reversi.ts +++ b/src/client/app/common/scripts/streaming/games/reversi.ts @@ -1,10 +1,10 @@ -import StreamManager from './stream-manager'; -import Stream from './stream'; -import MiOS from '../../../mios'; +import StreamManager from '../stream-manager'; +import Stream from '../stream'; +import MiOS from '../../../../mios'; export class ReversiStream extends Stream { constructor(os: MiOS, me) { - super(os, 'reversi', { + super(os, 'games/reversi', { i: me.token }); } diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts index 9a8d19adbd..e619764191 100644 --- a/src/client/app/mios.ts +++ b/src/client/app/mios.ts @@ -11,7 +11,7 @@ import { DriveStreamManager } from './common/scripts/streaming/drive'; import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats'; import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats'; import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index'; -import { ReversiStreamManager } from './common/scripts/streaming/reversi'; +import { ReversiStreamManager } from './common/scripts/streaming/games/reversi'; import Err from './common/views/components/connect-failed.vue'; import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline'; diff --git a/src/server/api/stream/reversi-game.ts b/src/server/api/stream/games/reversi-game.ts similarity index 96% rename from src/server/api/stream/reversi-game.ts rename to src/server/api/stream/games/reversi-game.ts index faa4e2f38a..2180e4fcde 100644 --- a/src/server/api/stream/reversi-game.ts +++ b/src/server/api/stream/games/reversi-game.ts @@ -1,10 +1,10 @@ import * as websocket from 'websocket'; import * as redis from 'redis'; -import * as CRC32 from 'crc-32'; -import ReversiGame, { pack } from '../../../models/games/reversi/game'; -import { publishReversiGameStream } from '../../../stream'; -import Reversi from '../../../games/reversi/core'; -import * as maps from '../../../games/reversi/maps'; +import * as CRC32 from 'crc-32/types'; +import ReversiGame, { pack } from '../../../../models/games/reversi/game'; +import { publishReversiGameStream } from '../../../../stream'; +import Reversi from '../../../../games/reversi/core'; +import * as maps from '../../../../games/reversi/maps'; import { ParsedUrlQuery } from 'querystring'; export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void { diff --git a/src/server/api/stream/reversi.ts b/src/server/api/stream/games/reversi.ts similarity index 86% rename from src/server/api/stream/reversi.ts rename to src/server/api/stream/games/reversi.ts index a76685d51f..3f23466520 100644 --- a/src/server/api/stream/reversi.ts +++ b/src/server/api/stream/games/reversi.ts @@ -1,8 +1,8 @@ import * as mongo from 'mongodb'; import * as websocket from 'websocket'; import * as redis from 'redis'; -import Matching, { pack } from '../../../models/games/reversi/matching'; -import publishUserStream from '../../../stream'; +import Matching, { pack } from '../../../../models/games/reversi/matching'; +import publishUserStream from '../../../../stream'; export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { // Subscribe reversi stream diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts index 81adff0b58..7c2245703e 100644 --- a/src/server/api/streaming.ts +++ b/src/server/api/streaming.ts @@ -10,8 +10,8 @@ import userListStream from './stream/user-list'; import driveStream from './stream/drive'; import messagingStream from './stream/messaging'; import messagingIndexStream from './stream/messaging-index'; -import reversiGameStream from './stream/reversi-game'; -import reversiStream from './stream/reversi'; +import reversiGameStream from './stream/games/reversi-game'; +import reversiStream from './stream/games/reversi'; import serverStatsStream from './stream/server-stats'; import notesStatsStream from './stream/notes-stats'; import { ParsedUrlQuery } from 'querystring'; @@ -50,7 +50,7 @@ module.exports = (server: http.Server) => { const q = request.resourceURL.query as ParsedUrlQuery; const [user, app] = await authenticate(q.i as string); - if (request.resourceURL.pathname === '/reversi-game') { + if (request.resourceURL.pathname === '/games/reversi-game') { reversiGameStream(request, connection, subscriber, user); return; } @@ -69,7 +69,7 @@ module.exports = (server: http.Server) => { request.resourceURL.pathname === '/drive' ? driveStream : request.resourceURL.pathname === '/messaging' ? messagingStream : request.resourceURL.pathname === '/messaging-index' ? messagingIndexStream : - request.resourceURL.pathname === '/reversi' ? reversiStream : + request.resourceURL.pathname === '/games/reversi' ? reversiStream : null; if (channel !== null) {