Files
cypress/packages/socket/README.md
T
Ben Kucera 47faf52e16 internal: use yarn workspace over lerna for individual package commands (#7644)
* use yarn workspace over lerna for individual package commands

* remove usage of wait-on

* fix readmes after regex replace

* revert wait-on changes

* update yarn.lock
2020-06-10 18:31:40 -04:00

45 lines
906 B
Markdown

# Socket
This is a shared lib for holding both the `socket.io` server and client.
## Using
```javascript
const socket = require("packages/socket")
// returns
{
server: require("socket.io"),
client: require("socket.io-client"),
getPathToClientSource: function () {
// returns path to the client 'socket.io.js' file
// for use in the browser
}
}
```
```javascript
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 = 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
```bash
yarn workspace @packages/socket test
```