Commit 0899179e authored by nanahira's avatar nanahira

client no longer be abstract

parent 027d4e8d
Pipeline #43194 passed with stages
in 59 seconds
import { filter, merge, Observable, Subject } from 'rxjs'; import { filter, merge, Observable, of, Subject } from 'rxjs';
import { map, share, take, takeUntil } from 'rxjs/operators'; import { map, share, take, takeUntil } from 'rxjs/operators';
import { Context } from '../app'; import { Context } from '../app';
import { import {
...@@ -21,12 +21,20 @@ import YGOProDeck from 'ygopro-deck-encode'; ...@@ -21,12 +21,20 @@ import YGOProDeck from 'ygopro-deck-encode';
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import { ClientRoomField } from '../utility/decorators'; import { ClientRoomField } from '../utility/decorators';
export abstract class Client { export class Client {
protected abstract _send(data: Buffer): Promise<void>; protected async _send(data: Buffer): Promise<void> {
protected abstract _receive(): Observable<Buffer<ArrayBufferLike>>; return Promise.resolve();
protected abstract _disconnect(): Promise<void>; }
protected abstract _onDisconnect(): Observable<void>; protected _receive(): Observable<Buffer<ArrayBufferLike>> {
abstract physicalIp(): string; return of();
}
protected async _disconnect(): Promise<void> {}
protected _onDisconnect(): Observable<void> {
return of();
}
physicalIp(): string {
return '';
}
// in handshake // in handshake
ip = ''; ip = '';
...@@ -86,7 +94,7 @@ export abstract class Client { ...@@ -86,7 +94,7 @@ export abstract class Client {
private sendQueue = new PQueue({ concurrency: 1 }); private sendQueue = new PQueue({ concurrency: 1 });
async send(data: YGOProStocBase) { async send(data: YGOProStocBase) {
if (this.disconnected) { if (this.disconnected) {
return; return;
} }
return this.sendQueue.add(async () => { return this.sendQueue.add(async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment