#websocket integration

36 messages · Page 1 of 1 (latest)

gray turret
#

are you interested in building a notification system?

gray turret
#

I'm also looking into this, I followed this in case you find anything.

#

Maybe the solution to this has something to do with building a custom express endpoint with socket.io and using the internal batch-jobs to trigger the emit?

#

yes, it is

#

the subscriber is one part of the puzzle for sure

#

it just has to run socket.emit() somehow

gray turret
#

ok so I dived into node_modules and added a socket and it seems like its working

#

here is the source code where we wanna put our socket

#

maybe if we make a fork and build a medusa-store directly from our fork?

#

a socket plugin?

#

I dont understand how plugins can spin up a new server

#

I was actually thinking of making a custom express server only for that job lol

gray turret
#

:/

#

maybe a seperate server then?

#

i was thinking something like

#

order placed -> medusa server subscriber calls POST on custom server -> custom server emits the POST message to everyone connected

#

polling on a 2s-5s frequency was my first thought, but I didnt wanna implement that xD

#

I was also thinking of adding a refresh every 15mins because sometimes timers break

#

well depends on the implementation

#

in my case it's like a fast-food place

#

I just need a notification every 5-10s I guess

#

I wanna make a custom admin page for normal users where they will receive new orders and be able to fullfill them

#

yeah we pretty much want the same thing

#

no its a small kiosk with an old man and a motorbike

#

yeah :/

#

i'm doing interviews atm and have no job so I thought Imma make a move and make him a website

#

and ask for % if it goes well

#

so I need an admin page that has a bell sound and inform him when new orders come in

#

it sure can, I was just trying to implement it more elegantly

#

I will pay for a VPS as well, so I wont get charged anything weird

gray turret
#

what we found so far:

  • Websockets are buggy when trying to integrate them using the plugin method

  • Maybe fiddling with the source code of medusa-cli, adding a websocket server on the index.js of the express app and build a store with that as base is the solution, didnt try

  • There are 2 solutions for now: polling every X seconds or creating a seperate repo/express server and using the Subscriber medusa API to send it the messages

undone hull
#

It uses server sent events