A websocket *client* module that implements [RFC6455](https://tools.ietf.org/html/rfc6455) (version 13) and provides a simple interface to send and receive messages.
The implementation supports fragmented messages, automatically respondes to ping requests and periodically pings if the server isn't communicating.
**SSL/TLS support**
Take note of constraints documented in the [net module](net.md).
## websocket.createClient()
Creates a new websocket client. This client should be stored in a variable and will provide all the functions to handle a connection.
When the connection becomes closed, the same client can still be reused - the callback functions are kept - and you can connect again to any server.
Before disposing the client, make sure to call `ws:close()`.
#### Syntax
`websocket.createClient()`
#### Parameters
none
#### Returns
`websocketclient`
#### Example
```lua
local ws = websocket.createClient()
-- ...
ws:close()
ws = nil
```
## websocket.client:close()
Closes a websocket connection. The client issues a close frame and attemtps to gracefully close the websocket.
If server doesn't reply, the connection is terminated after a small timeout.
This function can be called even if the websocket isn't connected.
This function must *always* be called before disposing the reference to the websocket client.
#### Syntax
`websocket:close()`
#### Parameters
none
#### Returns
`nil`
#### Example
```lua
ws = websocket.createClient()
ws:close()
ws:close() -- nothing will happen
ws = nil -- fully dispose the client as lua will now gc it