* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update CHANGELOG.md

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update CHANGELOG.md

* Update CHANGELOG.md

* wip

* Update CHANGELOG.md

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo 2018-10-07 11:06:17 +09:00 committed by GitHub
parent 0b98a2364b
commit d0570d7fe3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
126 changed files with 1812 additions and 2273 deletions

View file

@ -0,0 +1,30 @@
import autobind from 'autobind-decorator';
import * as mongo from 'mongodb';
import Matching, { pack } from '../../../../../models/games/reversi/matching';
import { publishMainStream } from '../../../../../stream';
import Channel from '../../channel';
export default class extends Channel {
@autobind
public async init(params: any) {
// Subscribe reversi stream
this.subscriber.on(`reversiStream:${this.user._id}`, data => {
this.send(data);
});
}
@autobind
public async onMessage(type: string, body: any) {
switch (type) {
case 'ping':
if (body.id == null) return;
const matching = await Matching.findOne({
parentId: this.user._id,
childId: new mongo.ObjectID(body.id)
});
if (matching == null) return;
publishMainStream(matching.childId, 'reversiInvited', await pack(matching, matching.childId));
break;
}
}
}