Query a player to determine the port on which its database server is running.

@param announcement the device announcement with which we detected a new player on the network.
554812
private void requestPlayerDBServerPort(DeviceAnnouncement announcement) {
        Socket socket = null;
        try {
            InetSocketAddress address = new InetSocketAddress(announcement.getAddress(), DB_SERVER_QUERY_PORT);
            socket = new Socket();
            socket.connect(address, socketTimeout.get());
            InputStream is = socket.getInputStream();
            OutputStream os = socket.getOutputStream();
            socket.setSoTimeout(socketTimeout.get());
            os.write(DB_SERVER_QUERY_PACKET);
            byte[] response = readResponseWithExpectedSize(is, 2, "database server port query packet");
            if (response.length == 2) {
                setPlayerDBServerPort(announcement.getNumber(), (int)Util.bytesToNumber(response, 0, 2));
            }
        } catch (java.net.ConnectException ce) {
            logger.info("Player " + announcement.getNumber() +
                    " doesn't answer rekordbox port queries, connection refused. Won't attempt to request metadata.");
        } catch (Exception e) {
            logger.warn("Problem requesting database server port number", e);
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    logger.warn("Problem closing database server port request socket", e);
                }
            }
        }
    }
301091
async def announce(self):
        
        # send a serialized event
        await self.event_broker.send(
            action_type=intialize_service_action(),
            payload=json.dumps(self.summarize())
        )
392881
private void updateDevices(DeviceAnnouncement announcement) {
        firstDeviceTime.compareAndSet(0, System.currentTimeMillis());
        devices.put(announcement.getAddress(), announcement);
    }
381464
function(player) {
		player.world = this;
		this.players[player.name.toLowerCase()] = player;
		this.announce(player.name+" has entered the world.");
		this.loadPlayerData(player);
	}
1164219
def announce(self, discovery):
        
        try:
            url = self.__discovery_url()
            logger.debug("making announce request to %s" % (url))
            response = None
            response = self.client.put(url,
                                       data=self.to_json(discovery),
                                       headers={"Content-Type": "application/json"},
                                       timeout=0.8)

            if response.status_code is 200:
                self.last_seen = datetime.now()
        except (requests.ConnectTimeout, requests.ConnectionError):
            logger.debug("announce", exc_info=True)
        finally:
            return response
166234
def announcement_posted_hook(request, obj):
    
    logger.debug("Announcement posted")

    if obj.notify_post:
        logger.debug("Announcement notify on")
        announcement_posted_twitter(request, obj)
        try:
            notify_all = obj.notify_email_all
        except AttributeError:
            notify_all = False

        try:
            if notify_all:
                announcement_posted_email(request, obj, True)
            else:
                announcement_posted_email(request, obj)
        except Exception as e:
            logger.error("Exception when emailing announcement: {}".format(e))
            messages.error(request, "Exception when emailing announcement: {}".format(e))
            raise e
    else:
        logger.debug("Announcement notify off")
933679
public synchronized void start() throws SocketException {
        if (!isRunning()) {
            DeviceFinder.getInstance().addLifecycleListener(lifecycleListener);
            DeviceFinder.getInstance().addDeviceAnnouncementListener(announcementListener);
            DeviceFinder.getInstance().start();
            for (DeviceAnnouncement device: DeviceFinder.getInstance().getCurrentDevices()) {
                requestPlayerDBServerPort(device);
            }

            new Thread(null, new Runnable() {
                @Override
                public void run() {
                    while (isRunning()) {
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            logger.warn("Interrupted sleeping to close idle dbserver clients");
                        }
                        closeIdleClients();
                    }
                    logger.info("Idle dbserver client closer shutting down.");
                }
            }, "Idle dbserver client closer").start();

            running.set(true);
            deliverLifecycleAnnouncement(logger, true);
        }
    }
32351
private void deliverFoundAnnouncement(final DeviceAnnouncement announcement) {
        for (final DeviceAnnouncementListener listener : getDeviceAnnouncementListeners()) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        listener.deviceFound(announcement);
                    } catch (Throwable t) {
                        logger.warn("Problem delivering device found announcement to listener", t);
                    }
                }
            });
        }
    }
440614
void broadcast(ClusterConfiguration config) {
    Message vote = voteInfo.toMessage();
    for (String server : config.getPeers()) {
      this.transport.send(server, vote);
    }
  }
343060
@Override
  public void handleNotification(NamespaceNotification n) {
    int queuedCount = 0;
    if (LOG.isDebugEnabled()) {
      LOG.debug("Handling " + NotifierUtils.asString(n) + " ...");
    }

    // Add the notification to the queues
    Set<Long> clientsForNotification = getClientsForNotification(n);
    if (clientsForNotification != null && clientsForNotification.size() > 0) {
      synchronized (clientsForNotification) {
        for (Long clientId : clientsForNotification) {
          ConcurrentLinkedQueue<NamespaceNotification> clientQueue =
              clientsData.get(clientId).queue;
          // Just test that the client wasn't removed meanwhile
          if (clientQueue == null) {
            continue;
          }
          clientQueue.add(n);
          queuedCount ++;
        }
      }
      
      ServerDispatcher.queuedNotificationsCount.addAndGet(queuedCount);
    }
    
    // Save it in history
    serverHistory.storeNotification(n);
    
    if (LOG.isDebugEnabled()) {
      LOG.debug("Done handling " + NotifierUtils.asString(n));
    }
  }
758656
def process_announcement( sender_namerec, op, working_dir ):
    
    node_config = get_blockstack_opts()

    # valid announcement
    announce_hash = op['message_hash']
    announcer_id = op['announcer_id']
   
    # verify that it came from this individual
    name_history = sender_namerec['history']
    allowed_value_hashes = []
    for block_height in name_history.keys():
        for historic_namerec in name_history[block_height]:
            if historic_namerec.get('value_hash'):
                allowed_value_hashes.append(historic_namerec['value_hash'])

    if announce_hash not in allowed_value_hashes:
        # this individual did not send this announcement
        log.warning("Announce hash {} not found in name history for {}".format(announce_hash, announcer_id))
        return 

    # go get it from Atlas
    zonefiles_dir = node_config.get('zonefiles', None)
    if not zonefiles_dir:
        log.warning("This node does not store zone files, so no announcement can be found")
        return 

    announce_text = get_atlas_zonefile_data(announce_hash, zonefiles_dir)
    if announce_text is None:
        log.warning("No zone file {} found".format(announce_hash))
        return

    # go append it 
    log.critical("ANNOUNCEMENT (from %s): %s\n------BEGIN MESSAGE------\n%s\n------END MESSAGE------\n" % (announcer_id, announce_hash, announce_text))         
    store_announcement( working_dir, announce_hash, announce_text )
1160626
private void handleTrackerConnectResponse(TrackerMessage message)
          throws AnnounceException {
    this.validateTrackerResponse(message);

    if (!(message instanceof ConnectionResponseMessage)) {
      throw new AnnounceException("Unexpected tracker message type " +
              message.getType().name() + "!");
    }

    UDPConnectResponseMessage connectResponse =
            (UDPConnectResponseMessage) message;

    this.connectionId = connectResponse.getConnectionId();
    Calendar now = Calendar.getInstance();
    now.add(Calendar.MINUTE, 1);
    this.connectionExpiration = now.getTime();
  }
1198601
def start_tcp_server(self, port):
        

        self.__tcp_server.port = port
        if not self.__tcp_server.online:
            if self.__tcp_server.start():
                self.__engine.notifications_manager.notify(
                    "{0} | TCP Server has started with '{1}' address on '{2}' port!".format(
                        self.__class__.__name__,
                        self.__address,
                        self.__port))
                return True
        else:
            self.__engine.notifications_manager.warnify(
                "{0} | TCP Server is already online!".format(self.__class__.__name__))
            return False
720895
public static void send(EntityPlayerMP player)
	{
		Packet packet = new Packet();
		MalisisCore.network.sendTo(packet, player);
	}
922890
public void announceMPStarted(
      int startMode,
      JsMessagingEngine me) throws SIResourceException, SIException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "announceMPStarted",
        new Object[] {
            startMode,
            me });

    // Drive mpStarted against the associated MQLink object
    if(_mqLinkObject != null)
      _mqLinkObject.mpStarted(startMode, me);

    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "announceMPStarted");
  }
1294038
protected void deliverLifecycleAnnouncement(final Logger logger, final boolean starting) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (final LifecycleListener listener : getLifecycleListeners()) {
                    try {
                        if (starting) {
                            listener.started(LifecycleParticipant.this);
                        } else {
                            listener.stopped(LifecycleParticipant.this);
                        }
                    } catch (Throwable t) {
                        logger.warn("Problem delivering lifecycle announcement to listener", t);
                    }
                }
            }
        }, "Lifecycle announcement delivery").start();
    }
1129244
def _on_message(self, socket, message):
        
        data = json.loads(message)
        message_type = None
        identifier = None
        subscription = None

        if 'type' in data:
            message_type = data['type']

        if 'identifier' in data:
            identifier = json.loads(data['identifier'])

        if identifier is not None:
            subscription = self.find_subscription(identifier)

        if subscription is not None:
            subscription.received(data)
        elif message_type == 'welcome':
            self.logger.debug('Welcome message received.')

            for subscription in self.subscriptions.values():
                if subscription.state == 'connection_pending':
                    subscription.create()

        elif message_type == 'ping':
            if self.log_ping:
                self.logger.debug('Ping received.')
        else:
            self.logger.warning('Message not supported. (Message: {})'.format(message))