Skip to content

Commit

Permalink
fix: channel terminates subscription when token has expired
Browse files Browse the repository at this point in the history
  • Loading branch information
w3b6x9 committed May 24, 2022
1 parent 2183a43 commit 4871211
Show file tree
Hide file tree
Showing 25 changed files with 349 additions and 2,467 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ node_modules
.supabase

config/prod.secret.exs

.idea
5 changes: 2 additions & 3 deletions assets/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"presets": [
"@babel/preset-env"
]
"presets": ["next/babel"],
"plugins": []
}
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Config
config :realtime, Realtime.Repo,
username: "postgres",
password: "postgres",
database: "realtime_test#{System.get_env("MIX_TEST_PARTITION")}",
database: "realtime_test",
hostname: "localhost",
pool: Ecto.Adapters.SQL.Sandbox

Expand Down
2 changes: 1 addition & 1 deletion example/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/babel","next/core-web-vitals"]
}
50 changes: 17 additions & 33 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@supabase/realtime-js": "^1.3.5",
"@supabase/realtime-js": "^1.7.2",
"antd": "^4.18.5",
"next": "12.1.0",
"react": "17.0.2",
Expand Down
10 changes: 4 additions & 6 deletions example/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Index() {
setConnButtonState({ loading: true, value: "Connection ..." })
localStorage.setItem("host", host)
localStorage.setItem("token", token)
let socket = new RealtimeClient(host, { params: { apikey: token } })
let socket = new RealtimeClient(host, { params: { apikey: token, vsndate: '2022-05-13' } })
socket.connect()
const realtime_config = {
"configs": {
Expand All @@ -40,9 +40,7 @@ export default function Index() {
},
"user_token": token
}
let channel = socket.channel('realtime:*', {
isNewVersion: true,
})
let channel = socket.channel('realtime:any')

// userChannel.on('presence', { event: 'SYNC' }, () => {
// setIsInitialStateSynced(true)
Expand All @@ -66,8 +64,8 @@ export default function Index() {
// ts: msg.commit_timestamp
// })
// setDataSource([...dataSource])
})
channel.on('realtime', { schema: 'public', table: 'messages' }, (msg) => {
// })
channel.on('realtime', { event: '*', schema: 'public', table: '*' }, (msg) => {
console.log("msg", msg)
// console.log('Got a message')
// dataSource.unshift({
Expand Down

0 comments on commit 4871211

Please sign in to comment.