-
Notifications
You must be signed in to change notification settings - Fork 18
feat: remote listener for multiple device setup #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
for displaying invoices across devices. Useful for a 2 device merchant setup.
| const url = new URL(window.location) | ||
| url.protocol = url.protocol === 'https:' ? 'wss' : 'ws' | ||
| url.pathname = `/api/v1/ws/${this.tposId}` | ||
| const ws = new WebSocket(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dni this is a common patter. Maybe we need an JS utils like wsFromPath()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add to my TODO!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is.
const websocketPrefix =
window.location.protocol === 'http:' ? 'ws://' : 'wss://'
const websocketUrl = `${websocketPrefix}${window.location.host}/api/v1/ws`so one could use those instead.
motorina0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| const url = new URL(window.location) | ||
| url.protocol = url.protocol === 'https:' ? 'wss' : 'ws' | ||
| url.pathname = `/api/v1/ws/${this.tposId}` | ||
| const ws = new WebSocket(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const ws = new WebSocket(url) | |
| const ws = new WebSocket(`${websocketUrl}/${this.tposId}`) |
Useful for merchants creating the order on one device and getting payments on another.