//--------------------------------------------------------------
void ofxMatrixNetworkServer::draw(int xRefPos, int yRefPos){
    
	ofSetHexColor(0xDDDDDD);
	ofDrawBitmapString("Matrix SERVER connect on port: "+ofToString(getPort()), xRefPos, yRefPos);
    
	//ofSetHexColor(0x000000);
	//ofRect(10, 60, ofGetWidth()-24, ofGetHeight() - 65 - 15);
    
	ofSetHexColor(0xDDDDDD);
    
	//for each connected client lets get the data being sent and lets print it to the screen
	for(unsigned int i = 0; i < (unsigned int)getLastID(); i++){
        
		if( !isClientConnected(i) )continue;
        
		//give each client its own color
		ofSetColor(255 - i*30, 255 - i * 20, 100 + i*40);
        
		//calculate where to draw the text
		int xPos = xRefPos + 5;
		int yPos = yRefPos + 15 + (12 * i * 4);
        
		//get the ip and port of the client
		string port = ofToString( getClientPort(i) );
		string ip   = getClientIP(i);
		string info = "client "+ofToString(i)+" -connected from "+ip+" on port: "+port;
        
		//draw the info text and the received text bellow it
		ofDrawBitmapString(info, xPos, yPos);
		//ofDrawBitmapString(storeText[i], 25, yPos + 10);
        
	}
    
}
/*----------------------------------------------------------------------------------------
 * Purpose: Display the address for the client listener
 * Input: commandArgument - A linked list that provides all the parameters the users typed 
 * 		in. This list is in the same order as they were typed.
 * 	clientThreadArguments - A struct providing the basic address information for the 
 * 		current connection.
 * 	commandNode - A pointer to the current node in the command tree structure.
 * Output:  0 for success or 1 for failure
 * Note:        
 * Kevin Burnett @ November 3, 2008
 * -------------------------------------------------------------------------------------*/
int cmdShowClients(commandArgument * ca, clientThreadArguments * client, commandNode * cn) {
	long* clientIDs = NULL;
	long clientID = 0;
	int clientCount = 0, i = 0;
	int clientPort = 0;
	char * clientAddress = NULL;

	clientCount = getActiveClientsIDs(&clientIDs, CLIENT_LISTENER_UPDATA);

	// display all clients
	if(clientCount>0) { 
		sendMessage(client->socket, "ID\taddress\t\tport\n");
		for(i = 0; i<clientCount; i++) {
			clientID = clientIDs[i];

			clientPort = getClientPort(clientID, CLIENT_LISTENER_UPDATA);
			clientAddress = getClientAddress(clientID, CLIENT_LISTENER_UPDATA);

			sendMessage(client->socket, "%d\t%s\t%d\n", clientID, clientAddress, clientPort);

			free(clientAddress);
		}
	}
	else {
		sendMessage(client->socket, "No active clients.\n");
	}

	free(clientIDs);
	return 0;
}
Exemple #3
0
/* Check the message to see if it's an update to our list of clients */
static void checkForClientUpdates(xPL_MessagePtr theMessage) {
  int clientPort = -1;
  int clientHeartbeatInterval = -1;
  Bool clientSigningOff = FALSE;
  hubClientPtr theClient = NULL;

  /* See if this is a heaertbeat message */
  if (!isHeartbeatMessage(theMessage)) return;

  /* See if this is a local message */
  if (!isLocalClient(theMessage)) return;

  /* See if this is a signoff message or not */
  clientSigningOff = isSignoffMessage(theMessage);

  /* Get the port #, if any */
  if ((clientPort = getClientPort(theMessage)) == -1) return;
  
  /* Get the interval for updates */
  clientHeartbeatInterval = getHeartbeatInterval(theMessage);

  /* Lookup client */
  if ((theClient = findClientByPort(clientPort)) == NULL) {
    /* If this is a signoff, we are done with it (signoff of */
    /* an unknown client is of no interest to us             */
    if (clientSigningOff) return;

    /* New client -- add to the list */
    addNewClient(theMessage, clientPort, clientHeartbeatInterval);
    return;
  }

  /* Check for client ident change */
  updateClientIdent(theMessage, theClient);

  /* See if heartbeat interval has changed */
  if (clientHeartbeatInterval != theClient->heartbeatInterval) {
    xPL_Debug("Changing heartbeat interval for client on port %s from %s minutes to %d",
	      theClient->clientPort, theClient->heartbeatInterval, clientHeartbeatInterval);
    theClient->heartbeatInterval = clientHeartbeatInterval;
  }

  /* Update last heart from time */
  theClient->lastHeardFromAt = time(NULL);
}