- function send(message, options) {
 - return new Promise(function(resolve, reject) {
 - switch (ws.readyState) {
 - case WebSocket.OPENING:
 - // This should never happen.
 - log.warn('Unable to send to OPENING client "%s"', id)
 - break
 - case WebSocket.OPEN:
 - // This is what SHOULD happen.
 - ws.send(message, options, function(err) {
 - return err ? reject(err) : resolve()
 - })
 - break
 - case WebSocket.CLOSING:
 - // Ok, a 'close' event should remove the client from the set
 - // soon.
 - log.debug('Websocket CLOSING: "%s"', id)
 - break
 - case WebSocket.CLOSED:
 - // This should never happen.
 - webdriverAgent.removeListener('frame', emitFrame)
 - webdriverAgent.removeListener('orientation', emitOrientation)
 - webdriverAgent.removeListener('actionId', emitActionId)
 - log.warn('Unable to send to CLOSED client "%s"', id)
 - break
 - }
 - })
 - }
 
Stikked
