initial streaming work
This commit is contained in:
parent
ddb6fb9217
commit
319bb4ac28
4 changed files with 76 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
import apiService from '../api/api.service.js'
|
||||
import apiService, { getMastodonSocketURI, handleMastoWS } from '../api/api.service.js'
|
||||
import timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service.js'
|
||||
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
|
||||
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
||||
|
@ -16,6 +16,19 @@ const backendInteractorService = credentials => ({
|
|||
return followRequestFetcher.startFetching({ store, credentials })
|
||||
},
|
||||
|
||||
startUserSocket ({ store, onMessage }) {
|
||||
const serv = store.rootState.instance.server.replace('https', 'wss')
|
||||
// const serb = 'ws://localhost:8080/'
|
||||
const url = serv + getMastodonSocketURI({ credentials, stream: 'user' })
|
||||
const socket = new WebSocket(url)
|
||||
console.log(socket)
|
||||
if (socket) {
|
||||
socket.addEventListener('message', (wsEvent) => onMessage(handleMastoWS(wsEvent)))
|
||||
} else {
|
||||
throw new Error('failed to connect to socket')
|
||||
}
|
||||
},
|
||||
|
||||
...Object.entries(apiService).reduce((acc, [key, func]) => {
|
||||
return {
|
||||
...acc,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue