forked from FoundKeyGang/FoundKey
Improve streaming API
This commit is contained in:
parent
9c0e990568
commit
6012e98ae6
17 changed files with 20 additions and 0 deletions
|
@ -9,6 +9,7 @@ export default abstract class Channel {
|
||||||
public id: string;
|
public id: string;
|
||||||
public abstract readonly chName: string;
|
public abstract readonly chName: string;
|
||||||
public static readonly shouldShare: boolean;
|
public static readonly shouldShare: boolean;
|
||||||
|
public static readonly requireCredential: boolean;
|
||||||
|
|
||||||
protected get user() {
|
protected get user() {
|
||||||
return this.connection.user;
|
return this.connection.user;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'apLog';
|
public readonly chName = 'apLog';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'drive';
|
public readonly chName = 'drive';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Channel from '../../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'gamesReversiGame';
|
public readonly chName = 'gamesReversiGame';
|
||||||
public static shouldShare = false;
|
public static shouldShare = false;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
private gameId: mongo.ObjectID;
|
private gameId: mongo.ObjectID;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'gamesReversi';
|
public readonly chName = 'gamesReversi';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'globalTimeline';
|
public readonly chName = 'globalTimeline';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
private mutedUserIds: string[] = [];
|
private mutedUserIds: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'hashtag';
|
public readonly chName = 'hashtag';
|
||||||
public static shouldShare = false;
|
public static shouldShare = false;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'homeTimeline';
|
public readonly chName = 'homeTimeline';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
private mutedUserIds: string[] = [];
|
private mutedUserIds: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'hybridTimeline';
|
public readonly chName = 'hybridTimeline';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
private mutedUserIds: string[] = [];
|
private mutedUserIds: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'localTimeline';
|
public readonly chName = 'localTimeline';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
private mutedUserIds: string[] = [];
|
private mutedUserIds: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'main';
|
public readonly chName = 'main';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'messagingIndex';
|
public readonly chName = 'messagingIndex';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'messaging';
|
public readonly chName = 'messaging';
|
||||||
public static shouldShare = false;
|
public static shouldShare = false;
|
||||||
|
public static requireCredential = true;
|
||||||
|
|
||||||
private otherpartyId: string;
|
private otherpartyId: string;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ const ev = new Xev();
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'notesStats';
|
public readonly chName = 'notesStats';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const ev = new Xev();
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'serverStats';
|
public readonly chName = 'serverStats';
|
||||||
public static shouldShare = true;
|
public static shouldShare = true;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Channel from '../channel';
|
||||||
export default class extends Channel {
|
export default class extends Channel {
|
||||||
public readonly chName = 'userList';
|
public readonly chName = 'userList';
|
||||||
public static shouldShare = false;
|
public static shouldShare = false;
|
||||||
|
public static requireCredential = false;
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async init(params: any) {
|
public async init(params: any) {
|
||||||
|
|
|
@ -173,6 +173,10 @@ export default class Connection {
|
||||||
*/
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public connectChannel(id: string, params: any, channel: string, pong = false) {
|
public connectChannel(id: string, params: any, channel: string, pong = false) {
|
||||||
|
if ((channels as any)[channel].requireCredential && this.user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視
|
// 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視
|
||||||
if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) {
|
if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue