Refactoring

This commit is contained in:
syuilo 2018-07-09 21:15:49 +09:00
parent 8b3cb850a5
commit 9201b5318b
6 changed files with 19 additions and 19 deletions

View File

@ -1,9 +1,9 @@
import Stream from './stream'; import Stream from '../stream';
import MiOS from '../../../mios'; import MiOS from '../../../../mios';
export class ReversiGameStream extends Stream { export class ReversiGameStream extends Stream {
constructor(os: MiOS, me, game) { constructor(os: MiOS, me, game) {
super(os, 'reversi-game', { super(os, 'games/reversi-game', {
i: me ? me.token : null, i: me ? me.token : null,
game: game.id game: game.id
}); });

View File

@ -1,10 +1,10 @@
import StreamManager from './stream-manager'; import StreamManager from '../stream-manager';
import Stream from './stream'; import Stream from '../stream';
import MiOS from '../../../mios'; import MiOS from '../../../../mios';
export class ReversiStream extends Stream { export class ReversiStream extends Stream {
constructor(os: MiOS, me) { constructor(os: MiOS, me) {
super(os, 'reversi', { super(os, 'games/reversi', {
i: me.token i: me.token
}); });
} }

View File

@ -11,7 +11,7 @@ import { DriveStreamManager } from './common/scripts/streaming/drive';
import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats'; import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats';
import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats'; import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats';
import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index'; 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 Err from './common/views/components/connect-failed.vue';
import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline'; import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline';

View File

@ -1,10 +1,10 @@
import * as websocket from 'websocket'; import * as websocket from 'websocket';
import * as redis from 'redis'; import * as redis from 'redis';
import * as CRC32 from 'crc-32'; import * as CRC32 from 'crc-32/types';
import ReversiGame, { pack } from '../../../models/games/reversi/game'; import ReversiGame, { pack } from '../../../../models/games/reversi/game';
import { publishReversiGameStream } from '../../../stream'; import { publishReversiGameStream } from '../../../../stream';
import Reversi from '../../../games/reversi/core'; import Reversi from '../../../../games/reversi/core';
import * as maps from '../../../games/reversi/maps'; import * as maps from '../../../../games/reversi/maps';
import { ParsedUrlQuery } from 'querystring'; import { ParsedUrlQuery } from 'querystring';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void { export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void {

View File

@ -1,8 +1,8 @@
import * as mongo from 'mongodb'; import * as mongo from 'mongodb';
import * as websocket from 'websocket'; import * as websocket from 'websocket';
import * as redis from 'redis'; import * as redis from 'redis';
import Matching, { pack } from '../../../models/games/reversi/matching'; import Matching, { pack } from '../../../../models/games/reversi/matching';
import publishUserStream from '../../../stream'; import publishUserStream from '../../../../stream';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
// Subscribe reversi stream // Subscribe reversi stream

View File

@ -10,8 +10,8 @@ import userListStream from './stream/user-list';
import driveStream from './stream/drive'; import driveStream from './stream/drive';
import messagingStream from './stream/messaging'; import messagingStream from './stream/messaging';
import messagingIndexStream from './stream/messaging-index'; import messagingIndexStream from './stream/messaging-index';
import reversiGameStream from './stream/reversi-game'; import reversiGameStream from './stream/games/reversi-game';
import reversiStream from './stream/reversi'; import reversiStream from './stream/games/reversi';
import serverStatsStream from './stream/server-stats'; import serverStatsStream from './stream/server-stats';
import notesStatsStream from './stream/notes-stats'; import notesStatsStream from './stream/notes-stats';
import { ParsedUrlQuery } from 'querystring'; import { ParsedUrlQuery } from 'querystring';
@ -50,7 +50,7 @@ module.exports = (server: http.Server) => {
const q = request.resourceURL.query as ParsedUrlQuery; const q = request.resourceURL.query as ParsedUrlQuery;
const [user, app] = await authenticate(q.i as string); 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); reversiGameStream(request, connection, subscriber, user);
return; return;
} }
@ -69,7 +69,7 @@ module.exports = (server: http.Server) => {
request.resourceURL.pathname === '/drive' ? driveStream : request.resourceURL.pathname === '/drive' ? driveStream :
request.resourceURL.pathname === '/messaging' ? messagingStream : request.resourceURL.pathname === '/messaging' ? messagingStream :
request.resourceURL.pathname === '/messaging-index' ? messagingIndexStream : request.resourceURL.pathname === '/messaging-index' ? messagingIndexStream :
request.resourceURL.pathname === '/reversi' ? reversiStream : request.resourceURL.pathname === '/games/reversi' ? reversiStream :
null; null;
if (channel !== null) { if (channel !== null) {