strapi/docs/features/websockets.md
2016-03-22 18:11:11 +01:00

786 B

title
WebSockets

Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed.

Configuration

Configuration:

  • Key: websockets
  • Environment: all
  • Location: ./config/general.json
  • Type: boolean

Example:

{
  "websockets": true
}

Notes:

  • Set to false to disable websockets with Socket.IO.

Usage

By default Strapi binds Socket.IO and your common websockets features are available using the io object.

io.on('connection', function (socket) {
  socket.emit('news', {
    hello: 'world'
  });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});