Files
cypress/packages/socket
Bill Glesias f14a11aecf chore: update eslint from version 7 to version 8 (#29355)
* chore: (for eslint-plugin-dev only is breaking) update eslint-plugin dev minimum to eslint 7. Remove support for coffeescript and reconfigured required peer deps

* correctly configure eslint-plugin-json-format for the monorepo and run linting on all json files (previously was not running)

* properly support no duplicate imports
2024-04-26 14:42:33 -04:00
..

Socket

This is a shared lib for holding both the socket.io server and client.

Using

const socket = require("@packages/socket")

// returns
{
  server: require("socket.io"),
  getPathToClientSource: function () {
    // returns path to the client 'socket.io.js' file
    // for use in the browser
  }
}
const socket = require("@packages/socket")

// server usage
const srv = require("http").createServer()
const io = socket.server(srv)
io.on("connection", function(){})

// client usage
const { client } = require("@packages/socket/lib/client")
const client = socket.client("http://localhost:2020")
client.on("connect", function(){})
client.on("event", function(){})
client.on("disconnect", function(){})

// path usage
socket.getPathToClientSource()
// returns your/path/to/node_modules/socket.io-client/socket.io.js0

Testing

yarn workspace @packages/socket test