Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions forex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ This demo application uses WebSocket to update forex price information in real-t

![FX Trader Application demo](Forex.png "FX Trader App Demo")

#To start this demo follow these steps:

**Prerequisite is that you have the Kaazing Websocket Gateway and ActiveMQ up and running (more information [here](https://kaazing.com/doc/5.0/about/setup-guide/index.html))**

1. Navigate in the terminal/command line to where you cloned the kaazing demos repository and to the /forex folder (ex: ~/demos/forex);
2. Navigate to /forex/feed/, here you can find:
for Linux/MacOS a script "forex.sh"
for Windows a bat "forex.bat";
**NOTE** If your ActiveMQ is **NOT** listening to tcp://localhost:61616 hen you run the script in the step above, you will have pass the URL that your ActiveMQ is listening to as the first parameter of the script, i.e.:
for Linux/MacOS - **./stock-trading-service tcp://{ACTIVEMQ.IP}:{ACTIVEMQ.PORT}**
for Windows - **.\stock-trading-service.bat tcp://{ACTIVEMQ.IP}:{ACTIVEMQ.PORT}**
4. Navigate to /forex/javascript/ and open index.html in your browser;
**NOTE** If your gateway is **NOT** accepting JMS connections on "ws://localhost:8000/jms" you will have edit the Location input to suite your gateway URI;
6. Click connect and you will see at the bottom of the page, the stock data will start to come in!
Enjoy!


To start building your own application with Kaazing Websocket Gateway, visit our [Getting Started](https://kaazing.com/getting-started/) page. </br>

Expand Down
93 changes: 93 additions & 0 deletions forex/feed/forex.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem forex startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and FOREX_JAR to pass JVM options to this script.
set DEFAULT_JVM_OPTS= -cp
set FOREX_JAR=forex-1.0.jar

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%lib\activemq-client-5.10.0.jar;%APP_HOME%lib\commons-codec-1.4.jar;%APP_HOME%lib\commons-logging-1.1.1.jar;%APP_HOME%lib\geronimo-j2ee-management_1.1_spec-1.0.1.jar;%APP_HOME%lib\geronimo-jms_1.1_spec-1.1.jar;%APP_HOME%lib\geronimo-jta_1.1_spec-1.1.jar;%APP_HOME%lib\gson-1.7.1.jar;%APP_HOME%lib\hawtbuf-1.10.jar;%APP_HOME%lib\httpclient-4.1.2.jar;%APP_HOME%lib\httpclient-cache-4.1.2.jar;%APP_HOME%lib\httpcore-4.1.2.jar;%APP_HOME%lib\httpmime-4.1.2.jar;%APP_HOME%lib\log4j-1.2.17.jar;%APP_HOME%lib\slf4j-api-1.7.5.jar;%APP_HOME%lib\slf4j-log4j12-1.7.5.jar;

echo %CLASSPATH%

@rem Execute stock-trading-service
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %FOREX_JAR%;"%CLASSPATH%" com.kaazing.gateway.samples.forex.ForexDemoService %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable FOREX if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%FOREX%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Empty file added forex/feed/logs/access.log
Empty file.
5,292 changes: 5,292 additions & 0 deletions forex/feed/logs/error.log

Large diffs are not rendered by default.

Empty file added forex/feed/logs/proxy.log
Empty file.
36 changes: 36 additions & 0 deletions forex/javascript/css/fxdemo.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,41 @@ body {
.main-container.waiting {
cursor: progress;
}
#locationUrl{
margin: 10px;
font-size: 16px;
line-height: 28px;
color: #000000;
}
#login_div{
background-color: #000; /*#4c4c4c;*/
font-size: 16px;
line-height: 28px;
color: #fff;
border-top: 1px solid #999;
border-bottom: 1px solid #666;
padding-left: 5px;
}
#connect{
background-color: #000; /*#4c4c4c;*/
font-size: 16px;
line-height: 28px;
color: #fff;
padding: 5px;
margin: 5px;
border-top: 1px solid #999;
border-bottom: 1px solid #666;
}
#disconnect{
background-color: #000; /*#4c4c4c;*/
font-size: 16px;
line-height: 28px;
color: #fff;
padding: 5px;
margin: 5px;
border-top: 1px solid #999;
border-bottom: 1px solid #666;
}
#masthead {
position: relative;
height:28px;
Expand All @@ -105,6 +140,7 @@ body {
border-top-left-radius: 10px;
-moz-border-radius-topleft: 10px;
}

#mastLeft {
width: 238px; /* 68 + 170; reset by js to 68 when clocks are set */
float:left;
Expand Down
11 changes: 9 additions & 2 deletions forex/javascript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ <h4>Javascript, WebSocket, JMS</h4>
</div>
<div class="main-container">
<!-- <header id="masthead"> changed to <div id="masthead">: IE 7-8 hack for background image missing if <header> or <section> -->

<div id="login_div" class="panel">
<span class="info">Please input your Kaazing Gateway URI</span><br/>
<label for="url">Location</label><input id="locationUrl" value="ws://localhost:8000/jms" /><br/>
<button id="connect">Connect</button>
<button id="disconnect">Close</button>
</div>
<div id="masthead">
<div id="mastLeft"></div>
<div id="slidePane">
Expand Down Expand Up @@ -589,8 +596,8 @@ <h3 class="inline">Alert</h3>
<script type="text/javascript" src="https://cdn.jsdelivr.net/g/rgraph@20131231(libraries/RGraph.common.core.js+libraries/RGraph.line.js)"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js" integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js" integrity="sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk=" crossorigin="anonymous"></script>
<script src="//cdn.kaazing.com/releases/enterprise.javascript.client/4.1.0/WebSocket.js"></script>
<script src="//cdn.kaazing.com/releases/enterprise.javascript.client/4.1.0/JmsClient.js"></script>
<script src="https://cdn.kaazing.com/releases/enterprise.javascript.client/4.1.0/WebSocket.js"></script>
<script src="https://cdn.kaazing.com/releases/enterprise.javascript.client/4.1.0/JmsClient.js"></script>
<script type="text/javascript" src="js/lab_utils.js"></script>
<script type="text/javascript" src="js/fxdemo.js"></script>
</html>
56 changes: 42 additions & 14 deletions forex/javascript/js/fxdemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,34 @@ window.onresize = function () {
if (widgetList['USDXAG']) {widgetList['USDXAG'].repaint;}
metricCnt.showStatus('Charts re-drawn.');
}*/

function handleConnect(message) {
console.log(message)
/* comment out for local testing */
//document.body.style.cursor = 'progress';
metricCnt.showStatus('Opening websockets...');
wsCtl.init(); //Kaazing websocket initializer
metricCnt.showStatus('Connection pending...');
// end testing
initMarketWatch();
}

$("#connect").click(function() {
handleConnect("Connection starting!!");
connect.disabled=true;
disconnect.disabled=false;
});

$("#disconnect").click(function() {
disconnect.disabled=true;
connect.disabled=false;
wsCtl.close();

});

$(document).ready(function() {
connect.disabled = false;
disconnect.disabled = false;
fxClk.set();
fxClk.timer = setInterval(fxClk.update, 1000);
attachDnDEvents();
Expand All @@ -459,13 +486,7 @@ $(document).ready(function() {
});
}
document.getElementById('rateSelect').msgRate[1].checked = true; // resets needed for Firefox reload
/* comment out for local testing */
document.body.style.cursor = 'progress';
metricCnt.showStatus('Opening websockets...');
wsCtl.init(); //Kaazing websocket initializer
metricCnt.showStatus('Connection pending...');
// end testing
initMarketWatch();


});
$(document).unload(function() {
Expand Down Expand Up @@ -1205,10 +1226,8 @@ function executionHistory(serverData, symbol) { // to allow a diffeent column se
| websocket connections adapted from Richard Clark's portfolio-completed.html |
|-----------------------------------------------------------------------------------|
*/
var wsUrl = makeURL ('jms', 'wss');
if (location.hostname==="localhost"){
wsUrl="ws://localhost:8000/jms";
}
var wsUrl = $('#locationUrl').attr('value');

var wsCtl = { //Kaazing Websocket control structure, isolate from naming conflicts via this object
debug : true,
fxDebug: true,
Expand All @@ -1222,9 +1241,11 @@ var wsCtl = { //Kaazing Websocket control structure, isolate from naming conflic
responseConsumer : null,
firstTopic : null,
init : function() {
if (wsCtl.fxDebug) console.log('url == ' + wsCtl.url);
var jmsConnectionFactory = new JmsConnectionFactory(wsCtl.url);
if (wsCtl.fxDebug) console.log(jmsConnectionFactory);
url = wsUrl;
if (wsCtl.fxDebug) console.log('url == ' + url);
var jmsConnectionFactory = new JmsConnectionFactory(url);

//if (wsCtl.fxDebug) console.log("TEST : " + jmsConnectionFactory);
var connectionFuture = jmsConnectionFactory.createConnection('','',function() {
try {
wsCtl.connection = connectionFuture.getValue();
Expand Down Expand Up @@ -1265,5 +1286,12 @@ var wsCtl = { //Kaazing Websocket control structure, isolate from naming conflic
document.body.style.cursor = 'default';
}
});
},
close: function(){
console.log("Disconnecting!");
wsCtl.connection.close(function () {
console.log("CONNECTION CLOSED");
updateConnectionButtons(false);
});
}
};