Websockets in Pages Functions?


Due to the newness of Functions, I haven’t been able to figure out the following use case.

What I want to do is:
Have my Function connect to a data stream/websocket, and then broadcast that data back to the caller via a separate websocket. So data flowing into the Function, and back out to the caller.

So questions follow:

  • Is it possible to use websockets with Functions, just like Workers?
  • Can my Function act as a client to a third party API’s websocket?
  • Can I share the flow of information between multiple Function invocations? e.g. for users that connect to the same edge point… global variable or similar.

If possible I would like to avoid registering with the third party API multiple times. Sharing one stream will be more efficient… though perhaps not a big deal.