refs #125 Apply global, hybrid and local timeline in websocket

This commit is contained in:
AkiraFukushima 2020-03-11 22:17:45 +09:00
parent e3c5db9a24
commit a249fd2948
4 changed files with 6 additions and 6 deletions

View file

@ -13,7 +13,7 @@ const access_token: string = process.env.MISSKEY_ACCESS_TOKEN
const client = generator('misskey', BASE_URL, access_token)
const stream: WebSocketInterface = client.userSocket()
const stream: WebSocketInterface = client.publicSocket()
const logger = log4js.getLogger()
logger.level = 'debug'

View file

@ -1864,11 +1864,11 @@ export default class Misskey implements MegalodonInterface {
}
public publicSocket(): WebSocketInterface {
throw new NoImplementedError('TODO: implement')
return this.client.socket('globalTimeline')
}
public localSocket(): WebSocketInterface {
throw new NoImplementedError('TODO: implement')
return this.client.socket('localTimeline')
}
public tagSocket(_tag: string): WebSocketInterface {

View file

@ -460,7 +460,7 @@ namespace MisskeyAPI {
return this.cancelTokenSource.cancel('Request is canceled by user')
}
public socket(channel: 'homeTimeline'): WebSocket {
public socket(channel: 'homeTimeline' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline'): WebSocket {
if (!this.accessToken) {
throw new Error('accessToken is required')
}

View file

@ -6,7 +6,7 @@ import MisskeyAPI from './api_client'
export default class WebSocket extends EventEmitter implements WebSocketInterface {
public url: string
public channel: 'homeTimeline'
public channel: 'homeTimeline' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline'
public parser: Parser
private _accessToken: string
private _reconnectInterval: number
@ -16,7 +16,7 @@ export default class WebSocket extends EventEmitter implements WebSocketInterfac
private _client: WS | null = null
private _channelID: string
constructor(url: string, channel: 'homeTimeline', accessToken: string) {
constructor(url: string, channel: 'homeTimeline' | 'localTimeline' | 'hybridTimeline' | 'globalTimeline', accessToken: string) {
super()
this.url = url
this.parser = new Parser()