WebsocketSender methods
773844
@Override
	public WebsocketFinalizer send(Function<? super HttpClientRequest, ? extends Publisher<Void>> sender) {
		Objects.requireNonNull(sender, "requestBody");
		return new WebsocketFinalizer(cachedConfiguration.bootstrap(b -> HttpClientConfiguration.body(b, (req, out) -> sender.apply(req))));
	}
249391
function Endpoint() {
  var self = this;
  const subscriptions = {};
  const ps = new Pubsub();
  this._publish = ps.publish;
  this._subscribe = ps.subscribe;
  this.active = false;
  this.connections = [];

  /**
   * Publishes a new connection.
   * @function _newConnection
   * @private
   * @param {string} sID socket ID
   * @returns this
   */
  this._newConnection = sId => {
    self.connections.push(sId || 'unknown');
    self.active = true;
    self._publish('change', {count: self.connections.length});
    return this;
  };

  /**
   * Records a lost connection.
   * @function _lostConnection
   * @private
   * @param {string} sID socket ID
   * @returns this
   */
  this._lostConnection = sId => {
    const index = this.connections.indexOf(sId);
    this.connections.splice(index, 1);
    if (this.connections.length === 0) {
      this.active = false;
    }

    self._publish('change', {count: self.connections.length});

    return this;
  };

  /**
   * Subscribe an action to perform when a message is received.
   * @function onmessage
   * @param {string} type
   * @param {messageResponse}
   * @param {boolean} [historical=false] Whether or not to call the listener if this message has been received before this listener was set.
   * @returns {subscription}
   */
  this.onmessage = (type, cb, historical = false) => {
    return self._subscribe(type, cb, historical);
  };

  /**
   * Subscribe an action to perform when the connection changes.
   * @function onchange
   * @param {changeCallback}
   * @returns {subscription}
   */
  this.onchange = cb => {
    return self._subscribe('change', cb);
  };

  /**
   * Remove all subscriptions to connection events.
   * @function clear
   */
  this.clear = ps.clear;
}
1374250
private function initWebsocketServer()
    {
        $websocketBind = $this->sandstoneApplication['sandstone.websocket.server']['bind'];
        $websocketPort = $this->sandstoneApplication['sandstone.websocket.server']['port'];

        $socket = new ReactSocketServer("$websocketBind:$websocketPort", $this->loop);

        new IoServer(
            new HttpServer(
                new WsServer(
                    new ServerProtocol(
                        new WebsocketApplication(
                            $this->sandstoneApplication
                        )
                    )
                )
            ),
            $socket
        );
    }
645937
private WebSocketMessage<?> receive(WebSocketEndpointConfiguration config, long timeout) {
        long timeLeft = timeout;

        WebSocketMessage<?> message = config.getHandler().getMessage();
        String path = endpointConfiguration.getEndpointUri();
        while (message == null && timeLeft > 0) {
            timeLeft -= endpointConfiguration.getPollingInterval();
            long sleep = timeLeft > 0 ? endpointConfiguration.getPollingInterval() : endpointConfiguration.getPollingInterval() + timeLeft;
            if (LOG.isDebugEnabled()) {
                String msg = "Waiting for message on '%s' - retrying in %s ms";
                LOG.debug(String.format(msg, path, (sleep)));
            }

            try {
                Thread.sleep(sleep);
            } catch (InterruptedException e) {
                LOG.warn(String.format("Thread interrupted while waiting for message on '%s'", path), e);
            }

            message = config.getHandler().getMessage();
        }

        if (message == null) {
            throw new ActionTimeoutException(String.format("Action timed out while receiving message on '%s'", path));
        }
        return message;
    }
417273
private Map<String, List<String>> shakeHands() throws WebSocketException
    {
        // The raw socket created by WebSocketFactory.
        Socket socket = mSocketConnector.getSocket();

        // Get the input stream of the socket.
        WebSocketInputStream input = openInputStream(socket);

        // Get the output stream of the socket.
        WebSocketOutputStream output = openOutputStream(socket);

        // Generate a value for Sec-WebSocket-Key.
        String key = generateWebSocketKey();

        // Send an opening handshake to the server.
        writeHandshake(output, key);

        // Read the response from the server.
        Map<String, List<String>> headers = readHandshake(input, key);

        // Keep the input stream and the output stream to pass them
        // to the reading thread and the writing thread later.
        mInput  = input;
        mOutput = output;

        // The handshake succeeded.
        return headers;
    }
171360
function wsConnect() {

            var typeOfConnection;

            if (location.protocol === 'https:') {
                typeOfConnection = 'wss';
            } else {
                typeOfConnection = 'ws'
            }

            self.ws = new WebSocket(typeOfConnection + '://' + location.hostname + ':' + location.port);

            self.ws.onopen = function (event) {

                //send an intial message to server and prove that the connection is built.
                self.send('connected', 'WSM: Browser confirms websocket connection.')

                reactive(self);

            };

            self.ws.onmessage = function (event) {
                // flags.binary will be set if a binary data is received.
                // flags.masked will be set if the data was masked.
                //console.log(event.data);

                self.processMessage(JSON.parse(event.data));
            };

            self.ws.onclose = function (event) {

                wsConnect();
            }
        }
943812
function TransportClient() {
        log.info("instantiate websocket");
        // get non-ambiguous this
        var self = this;
        // Call parent constructor
        TransportClient.super_.call(self);
        // Internal structures
        self._ws = undefined;
        self._id = _.uniqueId(); // debugging tool only
        self._state = "NOT_OPENED";
        // state listeners
        self.once("open", function handleOpened() {
            self._state = "OPEN";
        }).once("close", function handleClosed() {
            self._state = "CLOSED";
        });
        // constructor - return undefined
        return undefined;
    }
608265
private void writeMessageEmbeddedWebServerIpPort(Socket s) throws Exception {
    writeType(s, TYPE_EMBEDDED_WEB_SERVER_IP_PORT);
    writeString(s, _embeddedWebServerIp);
    writeInt(s, _embeddedWebServerPort);
  }
118941
function WebsocketClient(websocket, resourceName, keyPath) {
    var _this = _AbstractClient.call(this, resourceName, keyPath) || this;

    _this.websocket = websocket;
    _this.resourceName = resourceName;
    return _this;
  }
434824
def websocket_handler(request):
    """"""

    logger.debug('New websocket connection.')
    websocket = web.WebSocketResponse()
    yield from websocket.prepare(request)
    uuid = uuid4()
    request.app['dispatcher'].subscribe(uuid, websocket)

    while True:
        # Consume input buffer
        try:
            msg = yield from websocket.receive()
        except RuntimeError as e:
            logger.debug('Websocket exception: %s', str(e))
            break
        except CancelledError:
            logger.debug('Websocket closed')
            break
        if msg.type == aiohttp.WSMsgType.CLOSED:
            logger.debug('Websocket closed')
            break
        elif msg.type == aiohttp.WSMsgType.ERROR:
            logger.debug('Websocket exception: %s', websocket.exception())
            break

    request.app['dispatcher'].unsubscribe(uuid)
    return websocket
1342897
function _gpfHttpGenSend (methodName) {
    return function (httpObj, data) {
        if (data) {
            httpObj[methodName](data);
        } else {
            httpObj[methodName]();
        }
    };
}
654055
public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback<Void> callback, long timeoutmillis) {
        sendInternal(mergeBuffers(data), WebSocketFrameType.PONG, wsChannel, callback, null, timeoutmillis);
    }
41826
function ws(argv, callback) {
  if (!argv[2]) {
    console.error("url is required");
    console.error("Usage : ws <url>");
    process.exit(-1);
  }
  var uri = argv[2];
  var updatesVia = 'wss://' + uri.split('/')[2] + '/';

  var s;

  var connect = function(){
    s = new wss(updatesVia, {
      origin: 'http://websocket.org'
    });

    s.on('error', function() {
      callback('socket error');
      setTimeout(connect, RECONNECT);
    });

    s.on('open', function open() {
      var sub = 'sub ' + uri;
      callback(null, sub);
      s.send(sub);

      // periodically ping server
      setInterval(function() {
        var message = 'ping';
        debug(null, message);
        s.send(message);
      }, INTERVAL);
    });

  };
  connect();

  s.on('message', function message(data, flags) {
    callback(null, data);
  });

}
810113
function EventsBinder() {
    var listeners = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    classCallCheck(this, EventsBinder);

    this.listeners = listeners;
  }
1290277
public static synchronized void websocket(String url, AbstractReceiveListener endpoint) {
        checkStarted();
        instance().endpoints.add(HandlerUtil.websocket(url, endpoint));
    }
235091
@Override
  public void streamReply(WebSocket session,
                          HeadersAmp headers,
                          String to,
                          long qid,
                          int sequence,
                          List<Object> values,
                          Throwable exn,
                          boolean isComplete)
    throws IOException
  {
    /*
    if (values != null && values.size() > 0) {
      try (Writer out = session.getBasicRemote().getSendWriter()) {
        init(out);
        streamResult(headers, to, qid, values);
      }
    }
    
    if (exn != null) {
      try (Writer out = session.getBasicRemote().getSendWriter()) {
        init(out);
        streamError(headers, to, qid, exn);
      }
    }
    else if (isComplete) {
      try (Writer out = session.getBasicRemote().getSendWriter()) {
        init(out);
        streamComplete(headers, to, qid);
      }
    }
    */
  }
621040
protected function prepareWebsocketHandler()
    {
        $handlerClass = $this->container->make('config')->get('swoole_websocket.handler');

        if (! $handlerClass) {
            throw new WebsocketNotSetInConfigException;
        }

        $this->setWebsocketHandler($this->app->make($handlerClass));
    }