Send data / process request using $websocketBackend
Isn't the $websocketBackend supposed to act like httpbeckend mock, and send data / process messages? If not, how can I achieve this behaviour? So far I've found only nodeJS mock servers, not angular ones
Thank you in advance
Thanks for submitting the question. I'm not sure I understand the question correctly. Are you asking about how to use $websocketBackend mock with $websocket or how does $websocketBackend work with only one method .create()? Or are you asking how to use $websocket without a server aka including the mock version?
I'll try to explain better what I mean with the following scenario: I'have this websocket:
var ws = $websocket('ws://samplesite.data');
It sends data some data to samplesite.data using the send method:
ws.send(object);
I've also the following $websocketBackend:
var wsb = $websocketBackend('ws://samplesite.data');
How to make it send data back data to ws at the same way? I can't do:
wsb.send(object);
because it doesn't have a send method...
I thought that websockets could communicate in both ways, so if a $websocket can send data to a $websocketBackend, also the contrary should be possible... or am I wrong?
Thank you again
If you're using $websocketBackend on the server assuming you want to send data down to the client then yeah that doesn't work and I can explain why that is.
If you want to mock the server responses on the client then that's a different story and I can also explain how to do that.
Either way thanks for asking these questions since this means I need to update the docs to be more clear
Yes, if it doesn't requires too much of your time I'd be really glad to you for these explainations...
Thank you very very much for you support
I've found a library like angular-websocket that including a real mockserver, if you need some inspiration:
https://github.com/wilk/ng-websocket
sorry I didn't get to this. I think what you were looking for for my version was including angular-websocket.js then angular-websocket-mock.js afterwards to overwrite creating a real WebSocket. ng-websocket has a lot of features I planned on going forward with and they include mocks inside the source itself.
The last time I was working on this repo there was a problem of sticking with the w3c spec of how a websocket interface should be (not that simple) and then there are what others believe the interface should be (which is simple). I was planning on allowing the user to choose which interface they prefer, but that might be a little bit confusing not to mention how I would update the docs
@gdi2290 I'm also curious how you would mock server responses to the client using $websocketBackend. If you could provide some instruction here or update the docs, I'd appreciate it.
+1
I was looking for this feature today too but this thread confirmed it doesn't yet exist.