From 161fd4afab323ca6bf491def473f84bb7557b481 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 7 Mar 2018 17:48:32 +0900 Subject: wip --- src/web/app/common/mios.ts | 16 +- .../app/common/scripts/streaming/channel-stream.ts | 12 -- src/web/app/common/scripts/streaming/channel.ts | 12 ++ .../scripts/streaming/drive-stream-manager.ts | 20 -- .../app/common/scripts/streaming/drive-stream.ts | 12 -- src/web/app/common/scripts/streaming/drive.ts | 31 ++++ .../scripts/streaming/home-stream-manager.ts | 23 --- .../app/common/scripts/streaming/home-stream.ts | 36 ---- src/web/app/common/scripts/streaming/home.ts | 57 ++++++ .../streaming/messaging-index-stream-manager.ts | 20 -- .../scripts/streaming/messaging-index-stream.ts | 12 -- .../common/scripts/streaming/messaging-index.ts | 31 ++++ .../common/scripts/streaming/messaging-stream.ts | 19 -- src/web/app/common/scripts/streaming/messaging.ts | 19 ++ .../app/common/scripts/streaming/othello-game.ts | 10 + src/web/app/common/scripts/streaming/othello.ts | 28 +++ .../scripts/streaming/requests-stream-manager.ts | 12 -- .../common/scripts/streaming/requests-stream.ts | 10 - src/web/app/common/scripts/streaming/requests.ts | 21 +++ .../scripts/streaming/server-stream-manager.ts | 12 -- .../app/common/scripts/streaming/server-stream.ts | 10 - src/web/app/common/scripts/streaming/server.ts | 21 +++ .../app/common/views/components/messaging-room.vue | 4 +- .../app/common/views/components/othello.game.vue | 120 +++++++++++- src/web/app/common/views/components/othello.vue | 203 +++++++++++++++++++-- .../app/desktop/views/components/game-window.vue | 24 +++ .../app/desktop/views/components/ui.header.nav.vue | 19 +- .../app/desktop/views/widgets/channel.channel.vue | 2 +- 28 files changed, 580 insertions(+), 236 deletions(-) delete mode 100644 src/web/app/common/scripts/streaming/channel-stream.ts create mode 100644 src/web/app/common/scripts/streaming/channel.ts delete mode 100644 src/web/app/common/scripts/streaming/drive-stream-manager.ts delete mode 100644 src/web/app/common/scripts/streaming/drive-stream.ts create mode 100644 src/web/app/common/scripts/streaming/drive.ts delete mode 100644 src/web/app/common/scripts/streaming/home-stream-manager.ts delete mode 100644 src/web/app/common/scripts/streaming/home-stream.ts create mode 100644 src/web/app/common/scripts/streaming/home.ts delete mode 100644 src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts delete mode 100644 src/web/app/common/scripts/streaming/messaging-index-stream.ts create mode 100644 src/web/app/common/scripts/streaming/messaging-index.ts delete mode 100644 src/web/app/common/scripts/streaming/messaging-stream.ts create mode 100644 src/web/app/common/scripts/streaming/messaging.ts create mode 100644 src/web/app/common/scripts/streaming/othello-game.ts create mode 100644 src/web/app/common/scripts/streaming/othello.ts delete mode 100644 src/web/app/common/scripts/streaming/requests-stream-manager.ts delete mode 100644 src/web/app/common/scripts/streaming/requests-stream.ts create mode 100644 src/web/app/common/scripts/streaming/requests.ts delete mode 100644 src/web/app/common/scripts/streaming/server-stream-manager.ts delete mode 100644 src/web/app/common/scripts/streaming/server-stream.ts create mode 100644 src/web/app/common/scripts/streaming/server.ts create mode 100644 src/web/app/desktop/views/components/game-window.vue (limited to 'src/web') diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index cbb4400a73..3690d3171d 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -4,11 +4,12 @@ import * as merge from 'object-assign-deep'; import { host, apiUrl, swPublickey, version, lang, googleMapsApiKey } from '../config'; import Progress from './scripts/loading'; -import HomeStreamManager from './scripts/streaming/home-stream-manager'; -import DriveStreamManager from './scripts/streaming/drive-stream-manager'; -import ServerStreamManager from './scripts/streaming/server-stream-manager'; -import RequestsStreamManager from './scripts/streaming/requests-stream-manager'; -import MessagingIndexStreamManager from './scripts/streaming/messaging-index-stream-manager'; +import { HomeStreamManager } from './scripts/streaming/home'; +import { DriveStreamManager } from './scripts/streaming/drive'; +import { ServerStreamManager } from './scripts/streaming/server'; +import { RequestsStreamManager } from './scripts/streaming/requests'; +import { MessagingIndexStreamManager } from './scripts/streaming/messaging-index'; +import { OthelloStreamManager } from './scripts/streaming/othello'; import Err from '../common/views/components/connect-failed.vue'; @@ -117,11 +118,13 @@ export default class MiOS extends EventEmitter { serverStream: ServerStreamManager; requestsStream: RequestsStreamManager; messagingIndexStream: MessagingIndexStreamManager; + othelloStream: OthelloStreamManager; } = { driveStream: null, serverStream: null, requestsStream: null, - messagingIndexStream: null + messagingIndexStream: null, + othelloStream: null }; /** @@ -169,6 +172,7 @@ export default class MiOS extends EventEmitter { // Init other stream manager this.streams.driveStream = new DriveStreamManager(this.i); this.streams.messagingIndexStream = new MessagingIndexStreamManager(this.i); + this.streams.othelloStream = new OthelloStreamManager(this.i); }); if (this.debug) { diff --git a/src/web/app/common/scripts/streaming/channel-stream.ts b/src/web/app/common/scripts/streaming/channel-stream.ts deleted file mode 100644 index 434b108b9e..0000000000 --- a/src/web/app/common/scripts/streaming/channel-stream.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Stream from './stream'; - -/** - * Channel stream connection - */ -export default class Connection extends Stream { - constructor(channelId) { - super('channel', { - channel: channelId - }); - } -} diff --git a/src/web/app/common/scripts/streaming/channel.ts b/src/web/app/common/scripts/streaming/channel.ts new file mode 100644 index 0000000000..434b108b9e --- /dev/null +++ b/src/web/app/common/scripts/streaming/channel.ts @@ -0,0 +1,12 @@ +import Stream from './stream'; + +/** + * Channel stream connection + */ +export default class Connection extends Stream { + constructor(channelId) { + super('channel', { + channel: channelId + }); + } +} diff --git a/src/web/app/common/scripts/streaming/drive-stream-manager.ts b/src/web/app/common/scripts/streaming/drive-stream-manager.ts deleted file mode 100644 index 8acdd7cbba..0000000000 --- a/src/web/app/common/scripts/streaming/drive-stream-manager.ts +++ /dev/null @@ -1,20 +0,0 @@ -import StreamManager from './stream-manager'; -import Connection from './drive-stream'; - -export default class DriveStreamManager extends StreamManager { - private me; - - constructor(me) { - super(); - - this.me = me; - } - - public getConnection() { - if (this.connection == null) { - this.connection = new Connection(this.me); - } - - return this.connection; - } -} diff --git a/src/web/app/common/scripts/streaming/drive-stream.ts b/src/web/app/common/scripts/streaming/drive-stream.ts deleted file mode 100644 index 0da3f12554..0000000000 --- a/src/web/app/common/scripts/streaming/drive-stream.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Stream from './stream'; - -/** - * Drive stream connection - */ -export default class Connection extends Stream { - constructor(me) { - super('drive', { - i: me.token - }); - } -} diff --git a/src/web/app/common/scripts/streaming/drive.ts b/src/web/app/common/scripts/streaming/drive.ts new file mode 100644 index 0000000000..5805e58033 --- /dev/null +++ b/src/web/app/common/scripts/streaming/drive.ts @@ -0,0 +1,31 @@ +import Stream from './stream'; +import StreamManager from './stream-manager'; + +/** + * Drive stream connection + */ +export class DriveStream extends Stream { + constructor(me) { + super('drive', { + i: me.token + }); + } +} + +export class DriveStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new DriveStream(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/home-stream-manager.ts b/src/web/app/common/scripts/streaming/home-stream-manager.ts deleted file mode 100644 index ab56d5a73a..0000000000 --- a/src/web/app/common/scripts/streaming/home-stream-manager.ts +++ /dev/null @@ -1,23 +0,0 @@ -import StreamManager from './stream-manager'; -import Connection from './home-stream'; -import MiOS from '../../mios'; - -export default class HomeStreamManager extends StreamManager { - private me; - private os: MiOS; - - constructor(os: MiOS, me) { - super(); - - this.me = me; - this.os = os; - } - - public getConnection() { - if (this.connection == null) { - this.connection = new Connection(this.os, this.me); - } - - return this.connection; - } -} diff --git a/src/web/app/common/scripts/streaming/home-stream.ts b/src/web/app/common/scripts/streaming/home-stream.ts deleted file mode 100644 index 3516705e22..0000000000 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as merge from 'object-assign-deep'; - -import Stream from './stream'; -import MiOS from '../../mios'; - -/** - * Home stream connection - */ -export default class Connection extends Stream { - constructor(os: MiOS, me) { - super('', { - i: me.token - }); - - // 最終利用日時を更新するため定期的にaliveメッセージを送信 - setInterval(() => { - this.send({ type: 'alive' }); - me.last_used_at = new Date(); - }, 1000 * 60); - - // 自分の情報が更新されたとき - this.on('i_updated', i => { - if (os.debug) { - console.log('I updated:', i); - } - merge(me, i); - }); - - // トークンが再生成されたとき - // このままではAPIが利用できないので強制的にサインアウトさせる - this.on('my_token_regenerated', () => { - alert('%i18n:common.my-token-regenerated%'); - os.signout(); - }); - } -} diff --git a/src/web/app/common/scripts/streaming/home.ts b/src/web/app/common/scripts/streaming/home.ts new file mode 100644 index 0000000000..1f110bfd3b --- /dev/null +++ b/src/web/app/common/scripts/streaming/home.ts @@ -0,0 +1,57 @@ +import * as merge from 'object-assign-deep'; + +import Stream from './stream'; +import StreamManager from './stream-manager'; +import MiOS from '../../mios'; + +/** + * Home stream connection + */ +export class HomeStream extends Stream { + constructor(os: MiOS, me) { + super('', { + i: me.token + }); + + // 最終利用日時を更新するため定期的にaliveメッセージを送信 + setInterval(() => { + this.send({ type: 'alive' }); + me.last_used_at = new Date(); + }, 1000 * 60); + + // 自分の情報が更新されたとき + this.on('i_updated', i => { + if (os.debug) { + console.log('I updated:', i); + } + merge(me, i); + }); + + // トークンが再生成されたとき + // このままではAPIが利用できないので強制的にサインアウトさせる + this.on('my_token_regenerated', () => { + alert('%i18n:common.my-token-regenerated%'); + os.signout(); + }); + } +} + +export class HomeStreamManager extends StreamManager { + private me; + private os: MiOS; + + constructor(os: MiOS, me) { + super(); + + this.me = me; + this.os = os; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new HomeStream(this.os, this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts b/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts deleted file mode 100644 index 0f08b01481..0000000000 --- a/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts +++ /dev/null @@ -1,20 +0,0 @@ -import StreamManager from './stream-manager'; -import Connection from './messaging-index-stream'; - -export default class MessagingIndexStreamManager extends StreamManager { - private me; - - constructor(me) { - super(); - - this.me = me; - } - - public getConnection() { - if (this.connection == null) { - this.connection = new Connection(this.me); - } - - return this.connection; - } -} diff --git a/src/web/app/common/scripts/streaming/messaging-index-stream.ts b/src/web/app/common/scripts/streaming/messaging-index-stream.ts deleted file mode 100644 index 8015c840b4..0000000000 --- a/src/web/app/common/scripts/streaming/messaging-index-stream.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Stream from './stream'; - -/** - * Messaging index stream connection - */ -export default class Connection extends Stream { - constructor(me) { - super('messaging-index', { - i: me.token - }); - } -} diff --git a/src/web/app/common/scripts/streaming/messaging-index.ts b/src/web/app/common/scripts/streaming/messaging-index.ts new file mode 100644 index 0000000000..69758416dc --- /dev/null +++ b/src/web/app/common/scripts/streaming/messaging-index.ts @@ -0,0 +1,31 @@ +import Stream from './stream'; +import StreamManager from './stream-manager'; + +/** + * Messaging index stream connection + */ +export class MessagingIndexStream extends Stream { + constructor(me) { + super('messaging-index', { + i: me.token + }); + } +} + +export class MessagingIndexStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new MessagingIndexStream(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/messaging-stream.ts b/src/web/app/common/scripts/streaming/messaging-stream.ts deleted file mode 100644 index 68dfc5ec09..0000000000 --- a/src/web/app/common/scripts/streaming/messaging-stream.ts +++ /dev/null @@ -1,19 +0,0 @@ -import Stream from './stream'; - -/** - * Messaging stream connection - */ -export default class Connection extends Stream { - constructor(me, otherparty) { - super('messaging', { - i: me.token, - otherparty - }); - - (this as any).on('_connected_', () => { - this.send({ - i: me.token - }); - }); - } -} diff --git a/src/web/app/common/scripts/streaming/messaging.ts b/src/web/app/common/scripts/streaming/messaging.ts new file mode 100644 index 0000000000..1fff2286b3 --- /dev/null +++ b/src/web/app/common/scripts/streaming/messaging.ts @@ -0,0 +1,19 @@ +import Stream from './stream'; + +/** + * Messaging stream connection + */ +export class MessagingStream extends Stream { + constructor(me, otherparty) { + super('messaging', { + i: me.token, + otherparty + }); + + (this as any).on('_connected_', () => { + this.send({ + i: me.token + }); + }); + } +} diff --git a/src/web/app/common/scripts/streaming/othello-game.ts b/src/web/app/common/scripts/streaming/othello-game.ts new file mode 100644 index 0000000000..51a435541a --- /dev/null +++ b/src/web/app/common/scripts/streaming/othello-game.ts @@ -0,0 +1,10 @@ +import Stream from './stream'; + +export class OthelloGameStream extends Stream { + constructor(me, game) { + super('othello-game', { + i: me.token, + game: game.id + }); + } +} diff --git a/src/web/app/common/scripts/streaming/othello.ts b/src/web/app/common/scripts/streaming/othello.ts new file mode 100644 index 0000000000..febc5d498a --- /dev/null +++ b/src/web/app/common/scripts/streaming/othello.ts @@ -0,0 +1,28 @@ +import StreamManager from './stream-manager'; +import Stream from './stream'; + +export class OthelloStream extends Stream { + constructor(me) { + super('othello', { + i: me.token + }); + } +} + +export class OthelloStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new OthelloStream(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/requests-stream-manager.ts b/src/web/app/common/scripts/streaming/requests-stream-manager.ts deleted file mode 100644 index 44db913e78..0000000000 --- a/src/web/app/common/scripts/streaming/requests-stream-manager.ts +++ /dev/null @@ -1,12 +0,0 @@ -import StreamManager from './stream-manager'; -import Connection from './requests-stream'; - -export default class RequestsStreamManager extends StreamManager { - public getConnection() { - if (this.connection == null) { - this.connection = new Connection(); - } - - return this.connection; - } -} diff --git a/src/web/app/common/scripts/streaming/requests-stream.ts b/src/web/app/common/scripts/streaming/requests-stream.ts deleted file mode 100644 index 22ecea6c07..0000000000 --- a/src/web/app/common/scripts/streaming/requests-stream.ts +++ /dev/null @@ -1,10 +0,0 @@ -import Stream from './stream'; - -/** - * Requests stream connection - */ -export default class Connection extends Stream { - constructor() { - super('requests'); - } -} diff --git a/src/web/app/common/scripts/streaming/requests.ts b/src/web/app/common/scripts/streaming/requests.ts new file mode 100644 index 0000000000..5d199a0742 --- /dev/null +++ b/src/web/app/common/scripts/streaming/requests.ts @@ -0,0 +1,21 @@ +import Stream from './stream'; +import StreamManager from './stream-manager'; + +/** + * Requests stream connection + */ +export class RequestsStream extends Stream { + constructor() { + super('requests'); + } +} + +export class RequestsStreamManager extends StreamManager { + public getConnection() { + if (this.connection == null) { + this.connection = new RequestsStream(); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/server-stream-manager.ts b/src/web/app/common/scripts/streaming/server-stream-manager.ts deleted file mode 100644 index a170daebb9..0000000000 --- a/src/web/app/common/scripts/streaming/server-stream-manager.ts +++ /dev/null @@ -1,12 +0,0 @@ -import StreamManager from './stream-manager'; -import Connection from './server-stream'; - -export default class ServerStreamManager extends StreamManager { - public getConnection() { - if (this.connection == null) { - this.connection = new Connection(); - } - - return this.connection; - } -} diff --git a/src/web/app/common/scripts/streaming/server-stream.ts b/src/web/app/common/scripts/streaming/server-stream.ts deleted file mode 100644 index b9e0684465..0000000000 --- a/src/web/app/common/scripts/streaming/server-stream.ts +++ /dev/null @@ -1,10 +0,0 @@ -import Stream from './stream'; - -/** - * Server stream connection - */ -export default class Connection extends Stream { - constructor() { - super('server'); - } -} diff --git a/src/web/app/common/scripts/streaming/server.ts b/src/web/app/common/scripts/streaming/server.ts new file mode 100644 index 0000000000..b12198d2fd --- /dev/null +++ b/src/web/app/common/scripts/streaming/server.ts @@ -0,0 +1,21 @@ +import Stream from './stream'; +import StreamManager from './stream-manager'; + +/** + * Server stream connection + */ +export class ServerStream extends Stream { + constructor() { + super('server'); + } +} + +export class ServerStreamManager extends StreamManager { + public getConnection() { + if (this.connection == null) { + this.connection = new ServerStream(); + } + + return this.connection; + } +} diff --git a/src/web/app/common/views/components/messaging-room.vue b/src/web/app/common/views/components/messaging-room.vue index 637fa9cd60..547e9494e5 100644 --- a/src/web/app/common/views/components/messaging-room.vue +++ b/src/web/app/common/views/components/messaging-room.vue @@ -26,7 +26,7 @@ + + diff --git a/src/web/app/common/views/components/othello.vue b/src/web/app/common/views/components/othello.vue index f5abcfb103..f409f162f6 100644 --- a/src/web/app/common/views/components/othello.vue +++ b/src/web/app/common/views/components/othello.vue @@ -1,21 +1,53 @@
  • @@ -22,12 +29,6 @@

    %i18n:desktop.tags.mk-ui-header-nav.ch%

  • -
  • - - %fa:info% -

    %i18n:desktop.tags.mk-ui-header-nav.info%

    -
    -
  • @@ -36,11 +37,13 @@ import Vue from 'vue'; import { chUrl } from '../../../config'; import MkMessagingWindow from './messaging-window.vue'; +import MkGameWindow from './game-window.vue'; export default Vue.extend({ data() { return { hasUnreadMessagingMessages: false, + hasGameInvitations: false, connection: null, connectionId: null, chUrl @@ -80,6 +83,10 @@ export default Vue.extend({ messaging() { (this as any).os.new(MkMessagingWindow); + }, + + game() { + (this as any).os.new(MkGameWindow); } } }); diff --git a/src/web/app/desktop/views/widgets/channel.channel.vue b/src/web/app/desktop/views/widgets/channel.channel.vue index 70dac316cf..02cdf6de13 100644 --- a/src/web/app/desktop/views/widgets/channel.channel.vue +++ b/src/web/app/desktop/views/widgets/channel.channel.vue @@ -11,7 +11,7 @@