#include "testApp.h"
#include "stdio.h"

ofTCPServer TCP;

//--------------------------------------------------------------
void testApp::setup(){	 

	franklinBook.loadFont("type/frabk.ttf",16);
	verdana.loadFont("type/verdana.ttf",11);

	TCP.setup(11999);
}

//--------------------------------------------------------------
void testApp::update(){	
	ofBackground(30,30,30);

	for(int i = 0; i < TCP.getNumClients(); i++){
		TCP.send(i, "hello client - you are connected on port - "+ofToString(TCP.getClientPort(i)) );
	}
}

//--------------------------------------------------------------
void testApp::draw(){

	ofSetColor(0xD6261A);
	franklinBook.drawString("openFrameworks Mutli Client TCP Server Example \nconnect on port: "+ofToString(TCP.getPort()), 15, 30);

	for(int i = 0; i < TCP.getNumClients(); i++){
		verdana.drawString("client "+ofToString(i)+" - "+TCP.getClientIP(i)+":"+ofToString(TCP.getClientPort(i))+"\nmessage: "+TCP.receive(i), 15, 100 + 2*i*20);
	}
	
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){ 
}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
	
}

//--------------------------------------------------------------
void testApp::mouseReleased(){
}
