@@ -21,8 +21,8 @@
* Boston, MA 02111-1307 USA
*
* @author Paul Vollmer
* @modified 2012.04.23
* @version 0.0.1
* @modified 2012.04.24
* @version 0.0.1b
*/


@@ -38,38 +38,23 @@
//--------------------------------------------------------------
void testApp::setup(){

ofSetVerticalSync(true);
ofSetFrameRate(60);

// We set the updateManager App connection.
updateManager.connect();

}

//--------------------------------------------------------------
void testApp::update(){
if(ofGetFrameNum() == 25){
string shPath;
shPath = ofToDataPath( "openChildApp.sh", true );

char *shPathChar;
shPathChar = new char[ shPath.length() + 1 ];

strcpy( shPathChar, shPath.c_str() );

//--
int pid = fork();
cout << "pid :: " << pid << endl;

switch(pid){
case -1 :
cout << "Uh-Oh! fork() failed.\n" << endl;
case 0 :
execl( shPathChar, shPathChar, NULL );
default :
return;
}
}

}

//--------------------------------------------------------------
void testApp::draw(){
ofBackground( 255, 255, 255 );

ofBackground( 255, 255, 255 );
ofSetColor( 255, 0, 0 );
ofDrawBitmapString( "PARENT APPLICATION LAUNCHED.", 20, 20 );

@@ -78,6 +63,11 @@ void testApp::draw(){
//--------------------------------------------------------------
void testApp::keyPressed(int key){

// open our UpdatManager by pressing key '1'
if(key == '1'){
updateManager.open(ofToDataPath("openChildApp.sh", true));
}

}

//--------------------------------------------------------------
@@ -97,7 +87,11 @@ void testApp::mouseDragged(int x, int y, int button){

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


// send the app infos.
string temp = ofToString(x) + ", " + ofToString(y);
updateManager.send(temp);

}

//--------------------------------------------------------------
@@ -124,8 +118,3 @@ void testApp::dragEvent(ofDragInfo dragInfo){
void testApp::exit(){

}

//--------------------------------------------------------------
void testApp::urlResponse(ofHttpResponse & response){

}
@@ -21,16 +21,16 @@
* Boston, MA 02111-1307 USA
*
* @author Paul Vollmer
* @modified 2012.04.23
* @version 0.0.1
* @modified 2012.04.24
* @version 0.0.1b
*/



#pragma once

#include "ofMain.h"
#include "ofxAppUpdater.h"
#include "ofxUpdateManager.h"

using namespace wng;

@@ -54,13 +54,10 @@ class testApp : public ofBaseApp{
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void urlResponse(ofHttpResponse & response);
void exit();


private:
ofxAppUpdater updater;
bool updaterToggle;
ofxUpdateManager updateManager;


};
@@ -0,0 +1,121 @@
/**
* ofxUpdateManager.cpp is developed by Paul Vollmer
* http://www.wng.cc
*
*
* Copyright (c) 2012 Paul Vollmer
*
* ofxUpdateManager.cpp is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ofxUpdateManager.cpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with ofxUpdateManager.cpp; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Paul Vollmer
* @modified 2012.04.24
* @version 1.0.1d
*/



#include "ofxUpdateManager.h"



namespace wng {

ofxUpdateManager::ofxUpdateManager(){}


/**
* Create and connect the socket.
* Based on oF networkUdpSender-, ReceiverExample
*/
void ofxUpdateManager::connect(string ip, int port, bool blocking){
udpConnection.Create();
udpConnection.Connect(ip.c_str(), port);
udpConnection.SetNonBlocking(blocking);
}

void ofxUpdateManager::connect(){
connect("127.0.0.1", 11120119, true);
}





/**
* Create and bind the socket.
*/
void ofxUpdateManager::bind(int port, bool blocking){
udpConnection.Create();
udpConnection.Bind(port);
udpConnection.SetNonBlocking(blocking);
}

void ofxUpdateManager::bind(){
bind(11120119, true);
}





void ofxUpdateManager::send(string message){
int send = udpConnection.Send(message.c_str(), message.length());
}





string ofxUpdateManager::receive(){
// Network connection
char udpMessage[100000];
udpConnection.Receive(udpMessage,100000);
/*string message = udpMessage;
if(message!=""){
cout << message << endl;
}*/
return udpMessage;
}





void ofxUpdateManager::open(string shPath){

char *shPathChar;
shPathChar = new char[ shPath.length() + 1 ];

strcpy( shPathChar, shPath.c_str() );


int pid = fork();
cout << "pid :: " << pid << endl;

switch(pid){
case -1 :
cout << "Uh-Oh! fork() failed.\n" << endl;
case 0 :
execl( shPathChar, shPathChar, NULL );
default :
return;
}

}



}
@@ -0,0 +1,61 @@
/**
* ofxUpdateManager.h is developed by Paul Vollmer
* http://www.wng.cc
*
*
* Copyright (c) 2012 Paul Vollmer
*
* ofxUpdateManager.h is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ofxUpdateManager.h is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with ofxUpdateManager.h; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Paul Vollmer
* @modified 2012.04.24
* @version 1.0.1d
*/



#pragma once

#include "ofxNetwork.h"





namespace wng {

class ofxUpdateManager {

public:
ofxUpdateManager();

void connect(string ip, int port, bool blocking);
void connect();
void bind(int port, bool blocking);
void bind();
void send(string message);
string receive();
void open(string shPath);


private:
// Network connection to send/receive messages from
// other application.
ofxUDPManager udpConnection;

};

};