wip
This commit is contained in:
parent
768d0bdc00
commit
a78013d0e5
2 changed files with 3 additions and 38 deletions
|
@ -93,10 +93,6 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
|
|||
childId: me.id,
|
||||
});
|
||||
|
||||
if (other === 0) {
|
||||
publishMainStream(me.id, 'reversiNoInvites');
|
||||
}
|
||||
|
||||
return game;
|
||||
} else {
|
||||
const child = targetUser;
|
||||
|
@ -113,7 +109,6 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
|
|||
|
||||
const packed = await this.reversiMatchingsEntityService.pack(matching, child);
|
||||
this.globalEventService.publishReversiStream(child.id, 'invited', { game: packed });
|
||||
publishMainStream(child.id, 'reversiInvited', packed);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as CRC32 from 'crc-32';
|
||||
import type { MiReversiGame, MiUser, ReversiGamesRepository } from '@/models/_.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { ReversiService } from '@/core/ReversiService.js';
|
||||
import Channel, { type MiChannelService } from '../channel.js';
|
||||
|
||||
class ReversiChannel extends Channel {
|
||||
|
@ -19,9 +14,6 @@ class ReversiChannel extends Channel {
|
|||
public static kind = 'read:account';
|
||||
|
||||
constructor(
|
||||
private reversiService: ReversiService,
|
||||
private reversiGamesRepository: ReversiGamesRepository,
|
||||
|
||||
id: string,
|
||||
connection: Channel['connection'],
|
||||
) {
|
||||
|
@ -30,29 +22,13 @@ class ReversiChannel extends Channel {
|
|||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
this.subscriber.on(`reversiStream:${this.user.id}`, this.send);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async async onMessage(type: string, body: any) {
|
||||
switch (type) {
|
||||
case 'ping': {
|
||||
if (body.id == null) return;
|
||||
const matching = await ReversiMatchings.findOne({
|
||||
parentId: this.user!.id,
|
||||
childId: body.id,
|
||||
});
|
||||
if (matching == null) return;
|
||||
publishMainStream(matching.childId, 'reversiInvited', await ReversiMatchings.pack(matching, { id: matching.childId }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.subscriber.on(`reversiStream:${this.user!.id}`, this.send);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public dispose() {
|
||||
// Unsubscribe events
|
||||
this.subscriber.off(`reversiStream:${this.user.id}`, this.send);
|
||||
this.subscriber.off(`reversiStream:${this.user!.id}`, this.send);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,18 +39,12 @@ export class ReversiChannelService implements MiChannelService<true> {
|
|||
public readonly kind = ReversiChannel.kind;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.reversiGamesRepository)
|
||||
private reversiGamesRepository: ReversiGamesRepository,
|
||||
|
||||
private reversiService: ReversiService,
|
||||
) {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public create(id: string, connection: Channel['connection']): ReversiChannel {
|
||||
return new ReversiChannel(
|
||||
this.reversiService,
|
||||
this.reversiGamesRepository,
|
||||
id,
|
||||
connection,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue