ローカルタイムラインとグローバルタイムラインを実装
This commit is contained in:
@@ -9,11 +9,12 @@ import Connection from './scripts/streaming/stream';
|
||||
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';
|
||||
import { LocalTimelineStreamManager } from './scripts/streaming/local-timeline';
|
||||
import { GlobalTimelineStreamManager } from './scripts/streaming/global-timeline';
|
||||
|
||||
//#region api requests
|
||||
let spinner = null;
|
||||
@@ -116,15 +117,17 @@ export default class MiOS extends EventEmitter {
|
||||
* Connection managers
|
||||
*/
|
||||
public streams: {
|
||||
localTimelineStream: LocalTimelineStreamManager;
|
||||
globalTimelineStream: GlobalTimelineStreamManager;
|
||||
driveStream: DriveStreamManager;
|
||||
serverStream: ServerStreamManager;
|
||||
requestsStream: RequestsStreamManager;
|
||||
messagingIndexStream: MessagingIndexStreamManager;
|
||||
othelloStream: OthelloStreamManager;
|
||||
} = {
|
||||
localTimelineStream: null,
|
||||
globalTimelineStream: null,
|
||||
driveStream: null,
|
||||
serverStream: null,
|
||||
requestsStream: null,
|
||||
messagingIndexStream: null,
|
||||
othelloStream: null
|
||||
};
|
||||
@@ -231,13 +234,14 @@ export default class MiOS extends EventEmitter {
|
||||
public async init(callback) {
|
||||
//#region Init stream managers
|
||||
this.streams.serverStream = new ServerStreamManager(this);
|
||||
this.streams.requestsStream = new RequestsStreamManager(this);
|
||||
|
||||
this.once('signedin', () => {
|
||||
// Init home stream manager
|
||||
this.stream = new HomeStreamManager(this, this.i);
|
||||
|
||||
// Init other stream manager
|
||||
this.streams.localTimelineStream = new LocalTimelineStreamManager(this, this.i);
|
||||
this.streams.globalTimelineStream = new GlobalTimelineStreamManager(this, this.i);
|
||||
this.streams.driveStream = new DriveStreamManager(this, this.i);
|
||||
this.streams.messagingIndexStream = new MessagingIndexStreamManager(this, this.i);
|
||||
this.streams.othelloStream = new OthelloStreamManager(this, this.i);
|
||||
|
34
src/client/app/common/scripts/streaming/global-timeline.ts
Normal file
34
src/client/app/common/scripts/streaming/global-timeline.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import Stream from './stream';
|
||||
import StreamManager from './stream-manager';
|
||||
import MiOS from '../../mios';
|
||||
|
||||
/**
|
||||
* Global timeline stream connection
|
||||
*/
|
||||
export class GlobalTimelineStream extends Stream {
|
||||
constructor(os: MiOS, me) {
|
||||
super(os, 'global-timeline', {
|
||||
i: me.token
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class GlobalTimelineStreamManager extends StreamManager<GlobalTimelineStream> {
|
||||
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 GlobalTimelineStream(this.os, this.me);
|
||||
}
|
||||
|
||||
return this.connection;
|
||||
}
|
||||
}
|
34
src/client/app/common/scripts/streaming/local-timeline.ts
Normal file
34
src/client/app/common/scripts/streaming/local-timeline.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import Stream from './stream';
|
||||
import StreamManager from './stream-manager';
|
||||
import MiOS from '../../mios';
|
||||
|
||||
/**
|
||||
* Local timeline stream connection
|
||||
*/
|
||||
export class LocalTimelineStream extends Stream {
|
||||
constructor(os: MiOS, me) {
|
||||
super(os, 'local-timeline', {
|
||||
i: me.token
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class LocalTimelineStreamManager extends StreamManager<LocalTimelineStream> {
|
||||
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 LocalTimelineStream(this.os, this.me);
|
||||
}
|
||||
|
||||
return this.connection;
|
||||
}
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
import Stream from './stream';
|
||||
import StreamManager from './stream-manager';
|
||||
import MiOS from '../../mios';
|
||||
|
||||
/**
|
||||
* Requests stream connection
|
||||
*/
|
||||
export class RequestsStream extends Stream {
|
||||
constructor(os: MiOS) {
|
||||
super(os, 'requests');
|
||||
}
|
||||
}
|
||||
|
||||
export class RequestsStreamManager extends StreamManager<RequestsStream> {
|
||||
private os: MiOS;
|
||||
|
||||
constructor(os: MiOS) {
|
||||
super();
|
||||
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public getConnection() {
|
||||
if (this.connection == null) {
|
||||
this.connection = new RequestsStream(this.os);
|
||||
}
|
||||
|
||||
return this.connection;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user