//Xolotl Studio
//Created by Ymmanuel Flores
//Copyright 2018 Crowdorchestra SAPI de CV. All rights reserved.
//HHConnect v 1.0.0.4

{
    string $winName = "HedgehogConnect";

    if ( `window -exists $winName` == 1) {
        deleteUI $winName;
    }

    string $window = `window -t "Hedgehog Connect" -width 120 -height 200 $winName`;

    columnLayout -adjustableColumn true ;
    text -label "Port";
    string $portServer = `textField`;

    textField -edit -tx "8080" $portServer ;
    text -label "" ;
    string $button1 = `button -label "Start Listening" -command ("startServer "+ $portServer) `;
    text -label "" ;
    string $button2 = `button -label "Stop Listening" -command ("stopServer "+ $portServer) `;
    text -label "" ;

    proc startServer(string $port)
    {
        string $portNum = `textField -q -text $port`;
    	commandPort -n (":" + $portNum);
    	print "\nServer started\n";
    }

    proc stopServer(string $port)
    {
        string $portNum = `textField -q -text $port`;
    	commandPort -n (":" + $portNum) -cl;
    	print "\nServer stopped\n";
    }


    showWindow $window;
}
