-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
217 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import generator, { Entity, WebSocketInterface } from 'megalodon' | ||
import generator, { Entity } from 'megalodon' | ||
import log4js from 'log4js' | ||
|
||
const BASE_URL: string = process.env.FIREFISH_STREAMING_URL! | ||
const BASE_URL: string = process.env.FIREFISH_URL! | ||
const access_token: string = process.env.FIREFISH_ACCESS_TOKEN! | ||
|
||
const client = generator('firefish', BASE_URL, access_token) | ||
|
||
const stream: WebSocketInterface = client.userSocket() | ||
client.localStreaming().then(stream => { | ||
const logger = log4js.getLogger() | ||
logger.level = 'debug' | ||
stream.on('connect', () => { | ||
logger.debug('connect') | ||
}) | ||
|
||
const logger = log4js.getLogger() | ||
logger.level = 'debug' | ||
stream.on('connect', () => { | ||
logger.debug('connect') | ||
}) | ||
stream.on('pong', () => { | ||
logger.debug('pong') | ||
}) | ||
|
||
stream.on('pong', () => { | ||
logger.debug('pong') | ||
}) | ||
stream.on('update', (status: Entity.Status) => { | ||
logger.debug(status) | ||
}) | ||
|
||
stream.on('update', (status: Entity.Status) => { | ||
logger.debug(status) | ||
}) | ||
stream.on('notification', (notification: Entity.Notification) => { | ||
logger.debug(notification) | ||
}) | ||
|
||
stream.on('notification', (notification: Entity.Notification) => { | ||
logger.debug(notification) | ||
}) | ||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('close', () => { | ||
logger.debug('close') | ||
}) | ||
stream.on('close', () => { | ||
logger.debug('close') | ||
}) | ||
|
||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,49 @@ | ||
import generator, { Entity, WebSocketInterface } from 'megalodon' | ||
import generator, { Entity } from 'megalodon' | ||
|
||
const BASE_URL: string = process.env.MASTODON_STREAMING_URL! | ||
const BASE_URL: string = process.env.MASTODON_URL! | ||
|
||
const access_token: string = process.env.MASTODON_ACCESS_TOKEN! | ||
|
||
const client = generator('mastodon', BASE_URL, access_token) | ||
|
||
const stream: WebSocketInterface = client.localSocket() | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
client.localStreaming().then(stream => { | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
|
||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
|
||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
|
||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
|
||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
|
||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
|
||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
|
||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
|
||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
}) |
67 changes: 34 additions & 33 deletions
67
example/typescript/src/mastodon/unauthorized_streaming.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,53 @@ | ||
import generator, { Entity, WebSocketInterface } from 'megalodon' | ||
import generator, { Entity } from 'megalodon' | ||
|
||
declare var process: { | ||
env: { | ||
MASTODON_STREAMING_URL: string | ||
MASTODON_URL: string | ||
} | ||
} | ||
|
||
const url: string = process.env.MASTODON_STREAMING_URL | ||
const url: string = process.env.MASTODON_URL | ||
|
||
const client = generator('mastodon', url) | ||
|
||
const stream: WebSocketInterface = client.localSocket() | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
client.localStreaming().then(stream => { | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
|
||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
|
||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
|
||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
|
||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
|
||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
|
||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
|
||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
|
||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.