Callback when the WebSocket opening handshake completes.

        Enter the OPEN state and start the data transfer phase.
549596
def connection_open(self) -> None:
        
        # 4.1. The WebSocket Connection is Established.
        assert self.state is State.CONNECTING
        self.state = State.OPEN
        logger.debug("%s - state = OPEN", self.side)
        # Start the task that receives incoming WebSocket messages.
        self.transfer_data_task = self.loop.create_task(self.transfer_data())
        # Start the task that sends pings at regular intervals.
        self.keepalive_ping_task = self.loop.create_task(self.keepalive_ping())
        # Start the task that eventually closes the TCP connection.
        self.close_connection_task = self.loop.create_task(self.close_connection())
835189
def on_open(self, callback, timeout):
        
        super().on_open()
        self.callback = callback
        self.timeout = timeout
        self.revive_event = asyncio.Event(loop=self.loop)
76586
def _start_loop(self, websocket, event_handler):
		
		log.debug('Starting websocket loop')
		while True:
			try:
				yield from asyncio.wait_for(
					self._wait_for_message(websocket, event_handler),
					timeout=self.options['timeout']
				)
			except asyncio.TimeoutError:
				yield from websocket.pong()
				log.debug("Sending heartbeat...")
				continue
210890
def _on_connection_open(self, connection):
        
        _log.info("Successfully opened connection to %s", connection.params.host)
        self._channel = connection.channel(on_open_callback=self._on_channel_open)
135027
@Override
    public void connectionOpen() {
        lock.lock();
        try {
            connectionOpen = true;

            StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates) wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
            if (channels != null)
                storedChannel = channels.getUsableChannelForServerID(serverId);

            step = InitStep.WAITING_FOR_VERSION_NEGOTIATION;

            Protos.ClientVersion.Builder versionNegotiationBuilder = Protos.ClientVersion.newBuilder()
                    .setMajor(versionSelector.getRequestedMajorVersion())
                    .setMinor(versionSelector.getRequestedMinorVersion())
                    .setTimeWindowSecs(timeWindow);

            if (storedChannel != null) {
                versionNegotiationBuilder.setPreviousChannelContractHash(ByteString.copyFrom(storedChannel.contract.getTxId().getBytes()));
                log.info("Begun version handshake, attempting to reopen channel with contract hash {}", storedChannel.contract.getTxId());
            } else
                log.info("Begun version handshake creating new channel");

            conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
                    .setType(Protos.TwoWayChannelMessage.MessageType.CLIENT_VERSION)
                    .setClientVersion(versionNegotiationBuilder)
                    .build());
        } finally {
            lock.unlock();
        }
    }
44366
private void openAndBindSocket() {
    try {
      this.clientSocket = new MulticastSocket();
      Utils.selectAppropriateInterface(clientSocket);
      this.clientSocket.joinGroup(SsdpParams.getSsdpMulticastAddress());
    } catch (IOException e) {
      callback.onFailed(e);
    }
  }
726364
async def open(self, port, proxied_path=''):
        
        if not proxied_path.startswith('/'):
            proxied_path = '/' + proxied_path

        client_uri = self.get_client_uri('ws', port, proxied_path)
        headers = self.request.headers

        def message_cb(message):
            """
            Callback when the backend sends messages to us

            We just pass it back to the frontend
            """
            # Websockets support both string (utf-8) and binary data, so let's
            # make sure we signal that appropriately when proxying
            self._record_activity()
            if message is None:
                self.close()
            else:
                self.write_message(message, binary=isinstance(message, bytes))

        def ping_cb(data):
            """
            Callback when the backend sends pings to us.

            We just pass it back to the frontend.
            """
            self._record_activity()
            self.ping(data)

        async def start_websocket_connection():
            self.log.info('Trying to establish websocket connection to {}'.format(client_uri))
            self._record_activity()
            request = httpclient.HTTPRequest(url=client_uri, headers=headers)
            self.ws = await pingable_ws_connect(request=request,
                on_message_callback=message_cb, on_ping_callback=ping_cb)
            self._record_activity()
            self.log.info('Websocket connection established to {}'.format(client_uri))

        ioloop.IOLoop.current().add_callback(start_websocket_connection)
834307
async def write_close_frame(self, data: bytes = b"") -> None:
        
        # Test and set the connection state before sending the close frame to
        # avoid sending two frames in case of concurrent calls.
        if self.state is State.OPEN:
            # 7.1.3. The WebSocket Closing Handshake is Started
            self.state = State.CLOSING
            logger.debug("%s - state = CLOSING", self.side)

            # 7.1.2. Start the WebSocket Closing Handshake
            await self.write_frame(True, OP_CLOSE, data, _expected_state=State.CLOSING)
277776
def on_open(self, callback, period):
        
        super().on_open()
        self.callback = callback
        self.period = period
        self.reset_event = asyncio.Event(loop=self.loop)
205401
async def open_session(self, request: BaseRequestWebsocket) -> Session:
        """"""
        return await ensure_coroutine(self.session_interface.open_session)(self, request)
109056
def on_channel_open(self, channel):
        
        self.logger.debug('Channel opened')
        self.set_state(self.STATE_CONNECTED)
        self.channel = channel
        self.channel.add_on_close_callback(self.on_channel_closed)
        self.channel.add_on_cancel_callback(self.on_consumer_cancelled)
        if self.publisher_confirmations:
            self.delivery_tag = 0
            self.channel.confirm_delivery(self.on_confirmation)
            self.channel.add_on_return_callback(self.on_return)
        self.callbacks.on_ready(self.name)
933938
def on_connect(client):
    
    print "++ Opened connection to %s" % client.addrport()
    broadcast('%s joins the conversation.\n' % client.addrport() )
    CLIENT_LIST.append(client)
    client.send("Welcome to the Chat Server, %s.\n" % client.addrport() )
1321951
def on_channel_open(self, channel):
        
        self._logger.debug('Channel opened')
        self._channel = channel
        self._channel.parent_client = self
        self.add_on_channel_close_callback()
        self.setup_exchange(self._exchange)
324830
public void onOpen() {
    LOGGER.d("webSocket established...");
    connectionEstablished = true;
    retryConnectionCount = 0;
    for (AVConnectionListener listener: connectionListeners.values()) {
      listener.onWebSocketOpen();
    }

    resetConnectingStatus(true);

    // auto send login packet.
    LoginPacket lp = new LoginPacket();
    lp.setAppId(AVOSCloud.getApplicationId());
    lp.setInstallationId(AVInstallation.getCurrentInstallation().getInstallationId());
    this.sendPacket(lp);
  }
136965
function onmessage(data) {
          if (!handshaked) {
            handshaked = true;
            // The handshake output is in the form of URI.
            var result = url.parse(data, true).query;
            // A newly issued id for HTTP transport. It is used to identify which HTTP transport
            // is associated with which HTTP exchange. Don't confuse it with an id for socket,
            // `cettia-id`.
            self.id = result["cettia-transport-id"];
            // And then fire `open` event.
            self.emit("open");
          } else {
            // `code` is a first character of a message and used to recognize that delivered
            // message is text message or binary message.
            var code = data.substring(0, 1);
            data = data.substring(1);
            switch (code) {
              // If the `code` is `1`, the remainder of message is a plain text message. Fires
              // `text` event.
              case "1":
                self.emit("text", data);
                break;
              // If the `code` is `2`, the remainder of message is a Base64-encoded binary
              // message. Decodes it in Base64 and fires `binary` event.
              case "2":
                self.emit("binary", new Buffer(data, "base64"));
                break;
              // Otherwise, it is invalid. Fires an error and closes the connection.
              default:
                self.emit("error", new Error("protocol"));
                self.close();
                break;
            }
          }
        }
1152232
protected function handshake()
    {
        $key =        &$this->key;
        $lastPing =   &$this->lastPing;
        $that = $this;
        $logger = $this->logger;

        $query = http_build_query(
            ['login' => $this->gameData->getSystemInfo()->serverLogin]
        );
        $url = $this->handshakeUrl . '?' . $query;

        $lastPing = time();
        $this->logger->debug("[eXpansion analytics]Starting handshake");


        $this->http->put(
            $url,
            [],
            function (HttpResult $result) use (&$key, &$lastPing, $logger, $that) {
                $key = null;
                if ($result->getHttpCode() != '200') {
                    $logger->debug('[eXpansion analytics]Handshake failed', ['http_code' => $result->getHttpCode()]);
                    return;
                }

                $json = json_decode($result->getResponse());
                if (isset($json->key) && !empty($json->key)) {
                    $logger->debug('[eXpansion analytics]Handshake successfull', ['key' => $json->key]);

                    $key = $json->key;
                    $that->ping();

                    // allow ping just after handshake.
                    $lastPing = 0;
                }
            }
        );
    }
522349
private void handshake() {
        if (engine.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING) {
            // Not all SSLEngine implementations support calling beginHandshake multiple times while a handshake
            // is in progress. See https://github.com/netty/netty/issues/4718.
            return;
        } else {
            if (handshakePromise.isDone()) {
                // If the handshake is done already lets just return directly as there is no need to trigger it again.
                // This can happen if the handshake(...) was triggered before we called channelActive(...) by a
                // flush() that was triggered by a ChannelFutureListener that was added to the ChannelFuture returned
                // from the connect(...) method. In this case we will see the flush() happen before we had a chance to
                // call fireChannelActive() on the pipeline.
                return;
            }
        }

        // Begin handshake.
        final ChannelHandlerContext ctx = this.ctx;
        try {
            engine.beginHandshake();
            wrapNonAppData(ctx, false);
        } catch (Throwable e) {
            setHandshakeFailure(ctx, e);
        } finally {
            forceFlush(ctx);
        }
    }