// CentralConnected returns a Handler, which sets the specified function to be called when a device connects to the server.
331843
func CentralConnected(f func(Central)) Handler {
	return func(d Device) { d.(*device).centralConnected = f }
}
1252648
func OnDisconnect(onDisconnect func(remoteAddr string)) func(*wsConnection) {
	return func(wsc *wsConnection) {
		wsc.onDisconnect = onDisconnect
	}
}
1312051
func (c *Client) OnConnect(handler func()) {
	c.m.Lock()
	c.onConnectHandlers = append(c.onConnectHandlers, handler)
	c.m.Unlock()
}
808068
func (s *Session) IsConnected() bool {
	s.mu.RLock()
	defer s.mu.RUnlock()

	if s.cluster == nil || s.closed {
		return false
	}
	return s.cluster.IsConnected()
}
402937
func (p *chainMonitor) BlockConnectedHandler() {
	defer p.wg.Done()
out:
	for {
	keepon:
		select {
		case hash, ok := <-p.blockChan:
			if !ok {
				log.Warnf("Block connected channel closed.")
				break out
			}

			// Do not handle reorg and block connects simultaneously.
			p.reorgLock.Lock()
			// Collect block data.
			msgBlock, blockData, err := p.collect(hash)
			p.reorgLock.Unlock()
			if err != nil {
				log.Errorf("Failed to collect data for block %v: %v", hash, err)
				break keepon
			}

			// Store block data with each saver.
			for _, s := range p.dataSavers {
				if s != nil {
					// Save data to wherever the saver wants to put it.
					if err = s.Store(blockData, msgBlock); err != nil {
						log.Errorf("(%v).Store failed: %v", reflect.TypeOf(s), err)
					}
				}
			}

		case <-p.ctx.Done():
			log.Debugf("Got quit signal. Exiting block connected handler.")
			break out
		}
	}

}
914177
func BastionConnectFunc(
	bProto string,
	bAddr string,
	bConf *ssh.ClientConfig,
	proto string,
	addr string) func() (net.Conn, error) {
	return func() (net.Conn, error) {
		log.Printf("[DEBUG] Connecting to bastion: %s", bAddr)
		bastion, err := ssh.Dial(bProto, bAddr, bConf)
		if err != nil {
			return nil, fmt.Errorf("Error connecting to bastion: %s", err)
		}

		log.Printf("[DEBUG] Connecting via bastion (%s) to host: %s", bAddr, addr)
		conn, err := bastion.Dial(proto, addr)
		if err != nil {
			bastion.Close()
			return nil, err
		}

		// Wrap it up so we close both things properly
		return &bastionConn{
			Conn:    conn,
			Bastion: bastion,
		}, nil
	}
}
104173
func (s *Server) OnConnection(ws *websocket.Conn) {
	defer func() {
		ws.Close()
	}()

	client := NewClient(ws, s.hub)
	s.hub.Register(client)
	client.Listen()
}
1177616
func (ac *addrConn) connect() error {
	ac.mu.Lock()
	if ac.state == connectivity.Shutdown {
		ac.mu.Unlock()
		return errConnClosing
	}
	if ac.state != connectivity.Idle {
		ac.mu.Unlock()
		return nil
	}
	ac.updateConnectivityState(connectivity.Connecting)
	ac.mu.Unlock()

	// Start a goroutine connecting to the server asynchronously.
	go ac.resetTransport()
	return nil
}
368940
func (c *Client) IsConnected() bool {
	c.RLock()
	defer c.RUnlock()
	return c.connected
}
770674
func (mw *requestIDMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc {
	return func(w rest.ResponseWriter, r *rest.Request) {
		uuid := random.UUID()

		w.Header().Add("X-Request-ID", uuid)
		r.Env["REQUEST_ID"] = &uuid

		h(w, r)
	}
}
1266708
func (s *Server) OnDisconnect(f func(*Client)) {
	s.eventHub.Subscribe(clientDisconnected, func(e hub.Event) {
		go f(e.(disconnectionEvent).Client)
	})
}
805174
func (l Listener) OnDisconnect(e *gumble.DisconnectEvent) {
	if l.Disconnect != nil {
		l.Disconnect(e)
	}
}
997549
func (kea *KamEvapi) Connected() bool {
	kea.connMutex.RLock()
	defer kea.connMutex.RUnlock()
	if kea.conn == nil {
		return false
	}
	return true
}
386895
func (nc *Conn) ConnectedUrl() string {
	if nc == nil {
		return _EMPTY_
	}

	nc.mu.RLock()
	defer nc.mu.RUnlock()

	if nc.status != CONNECTED {
		return _EMPTY_
	}
	return nc.current.url.String()
}
568890
func (s *Serf) handleReconnect() {
	for {
		select {
		case <-time.After(s.config.ReconnectInterval):
			s.reconnect()
		case <-s.shutdownCh:
			return
		}
	}
}
1121148
func (bchf HandlerFunc) ServeConnection(conn net.Conn, bufr *bufio.Reader) {
	bchf(conn, bufr)
}
1351869
func GamepadConnected(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "gamepadconnected", Listener: listener}
}