Files
cypress/packages/socket
Bill Glesias eed699eb6d chore: update lerna to 8.1.8 from 6.6.2 (#30436)
* fix sync script with updateds npm-packlist

* chore: update lerna from 6.6.2 to 8.1.8 and ran lerna repair

* chore: pin typescript to ~5.4.5 to avoid importsNotUsedAsValues that was removed in 5.5 and edit workflows and scripts to correctly scope learna packages on v8 snapshot tests [run ci]

* fix indentation in comments

* remove console.log reference to print current package directory in sync exported npm with cli script
2024-10-22 14:46:46 -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