Simulate websocket data #24

Closed
samselikoff opened this Issue Feb 24, 2015 · 9 comments

Projects

None yet

5 participants

@samselikoff
Owner

I wonder if we simulate websocket responses with this lib, with something like long polling. That would be amazing. You could return an array from the route, and specify some settings for throttling the responses.

@samselikoff samselikoff changed the title from Simulate websocket data? to Simulate websocket data May 16, 2015
@samselikoff
Owner

Plan is to use https://github.com/thoov/mock-socket for this

@samselikoff
Owner

messed around and got this working in a socket.io app. notes for later:

var mockServer = new MockServer('ws://localhost:3003/api');
mockServer.on('connect_error', function(server) {
  console.log('err');
});
mockServer.on('connection', function(server) {
  server.emit('encode:add', {
    encode: {
      uniqueId: "123",
      command: "ffmpeg -threads 8 -ss 812.3532083333331 -i /mnt/back/2014G-S04-C02.mov -y -acodec copy -vcodec copy -t 285.53525 -map 0:0 -map 0:1 -map 0:3 -timecode 00:00:26:07 -f mov /mnt/back/2014G-Kohn_Sally-3317-S04-C02.mov",
      inputPath: "/path/to/something",
      outputPath: "/path/to/another/thing",
      setting: "",
      options: ""
    }
  });
});

window.io = MockSocket;
@samselikoff
Owner

Follow #165

@erichonkanen

hey just wondering if this will land soon? new to mirage but wondering how to mock my websocket connection.. seems cool

@samselikoff
Owner

its a bit lower priority right now :/

@ballPointPenguin
Contributor

This is something I am interested in as well. Currently, I'm just returning {} from all socket requests via mirage, which gets me through the day, but if I have time + ideas I'd love to help this story along.

@samselikoff samselikoff added the icebox label Jun 4, 2016
@dzbo
dzbo commented Oct 21, 2016

@ballPointPenguin how do you mock WS in mirage?

@ballPointPenguin
Contributor

@dzbo I'm just doing:

  this.get('/socket.io', () => ({}));
  this.post('/socket.io', () => ({}));

just to suppress errors in my app. I suppose you could do something more creative here too.

@samselikoff
Owner

Closing for now. Making a card in the roadmap.

If anyone is motivated to take this on, ping me.

@samselikoff samselikoff removed the icebox label Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment