feathersjs-ecosystem / socketio

[MOVED] The Feathers Socket.io websocket transport plugin
https://github.com/feathersjs/feathers
MIT License
37 stars 14 forks source link

Regarding plain websockets #34

Closed Upguard closed 8 years ago

Upguard commented 8 years ago

Necessary backstory: I'm creating an ad network where publishers embed my script file into their page. This means I'm unable to import any other files, so I'm reliant on what's already built into javascript.

I'm trying to communicate with my feathersjs socket, but I can only do so with the plain old Websocket()

Ex: var socket = new Websocket('myfeatherssocketurl')

Is this even possible? I noticed in the docs that when emitting something to the socket, you have to include an event name when you send the data, ex: socket.emit('message::create'), but you can't do that with an ordinary socket.

Is it possible to accomplish this with an ordinary socket?

daffl commented 8 years ago

You could still build the Socket.io or Primus websocket library into your JS.

Primus with the SockJS adapter might get you a ways, too. I'm pretty sure it is just encoding the event name + the body as the message string. I found this article describing how to connect to a SockJS server with plain websockets but you might have to dig through Primus to find out how it wants the messages to be encoded.

Upguard commented 8 years ago

I will check out Primus and the provided article, thanks for the guidance @daffl!