Skip to content

Commit 2a3d257

Browse files
author
Wasin Waeosri
committed
Merge branch 'v5_revisecodeandCDN'
Update project to bundle with jQuery and Bootstrap libraries (with license declare). Update README.md to match project detail.
2 parents 1364877 + c23ddb6 commit 2a3d257

24 files changed

Lines changed: 10114 additions & 28 deletions

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
libs/jquery-3.2.1.min.js
2-
bootstrap/
31
test.html

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2017 Thomson Reuters
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,39 @@
33

44
[Elektron WebSocket API](https://developers.thomsonreuters.com/elektron/websocket-api-early-access) enables easy integration into a multitude of client technology environments such as scripting and web. This API runs directly on your TREP infrastructure or the Thomson Reuters platform and presents data in an open (JSON) readable format. The API supports all Thomson Reuters Elektron data models and can be integrated into multiple client technology standards e.g. Python, R, .Net etc.
55

6-
The web browsers JavaScript runtime is a single-threaded environment. This limitation makes JavaScript cannot concurrent handles UI events, query, data processing and network connection logic which causes the UI blocking scenario in the web browsers. The HTML standard's introduces the [Web Workers](https://html.spec.whatwg.org/multipage/workers.html) to solve this issue. It lets web browsers run JavaScripts in background threads without blocking the UI. It can perform I/O, XMLHttpRequest and the WebSocket connection in a background thread while the main JavaScript thread handles UI interaction.
6+
The web browsers JavaScript runtime is a single-threaded environment by default. However, the HTML standard lets developers implement multi threads JavaScript application in web browser by introducing the [Web Workers](https://html.spec.whatwg.org/multipage/workers.html) feature that lets web browsers run JavaScripts in a main thread and a background thread (workers thread).
77

8-
There are two types of the Web Workers, [Dedicated Workers](https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface) and [Shared Workers](https://html.spec.whatwg.org/multipage/workers.html#sharedworker). This example covers only how to implement the Elektron WebSocket API with JavaScript web browser application with Dedicated Workers. The example lets the Web Workers handle a connection logic with Elektron WebSocket API in a separate thread while the main thread handles the UI events and displaying data.
8+
This example shows how to implement the Elektron WebSocket API with JavaScript web application with Web Workers. It lets the Web Workers thread handles a connection logic with ADS WebSocket while the main thread handles the UI interaction events and displaying data.
9+
10+
There are two types of the Web Workers, [Dedicated Workers](https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface) and [Shared Workers](https://html.spec.whatwg.org/multipage/workers.html#sharedworker). This example covers only how to implement the Elektron WebSocket API with JavaScript web browser application with Dedicated Workers.
911

1012
## Supported Web Browsers
11-
The example supports Chrome, Firefox and IE11 (based on the WebSocket and Web Workers browser supported).
13+
The example supports Chrome, Firefox and IE11 (based on the WebSocket and Web Workers browser supported platform).
1214

1315
## Prerequisite
14-
The following libraries are required for this example. They are need to be downloaded separately:
15-
1. [jQuery 3.2.1](https://jquery.com/)
16+
This example uses the following 3rd party libraries.
17+
1. [jQuery 3.2.1](https://jquery.com/)
1618
2. [Bootstrap 3.3.7](https://getbootstrap.com/docs/3.3/)
1719

18-
## Example files
20+
Both of jQuery and Bootstrap are distributed under the [MIT license](https://opensource.org/licenses/MIT). Please see more detail in the LICENSE.md file.
21+
22+
## Example files and folders
1923
The web application contains the following example files and folder:
2024
1. index.html: The application HTML page
2125
2. app/market_price_app.js: The application main file
2226
3. app/ws_workers.js: The application Web Workers file
2327
4. css/cover.css: The application CSS file
24-
5. libs/jquery-3.2.1.min.js: jQuery library file (need to be downloaded separately)
25-
6. bootstrap/css, bootstarp/fonts and bootstrap/js folders: The folders for Bootstrap CSS and libraries files (need to be downloaded separately)
28+
5. libs/jquery-3.2.1.min.js: jQuery library file
29+
6. bootstrap/css, bootstarp/fonts and bootstrap/js folders: The folders for Bootstrap CSS and libraries files
2630

2731
## How to run this example
28-
1. Deploy the project in any web server
29-
2. Open <web server>/index.html in the web browser (IE11, Chorme and Firefox)
32+
1. Deploy the project in any web server (recommend [http-server](https://www.npmjs.com/package/http-server) for quick dev/testing)
33+
2. Open <web server>/index.html in the web browsers (IE11, Chorme and Firefox)
3034

3135
## References
3236
For further details, please check out the following resources:
3337
* [Thomson Reuters Elektron WebSocket API page](https://developers.thomsonreuters.com/elektron/websocket-api-early-access) on the [Thomson Reuters Developer Community](https://developers.thomsonreuters.com/) web site.
3438
* [Mozilla Developer Network: Web Workers API page](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
3539
* [Google HTML5 Rocks: The Basics of Web Workers page](https://www.html5rocks.com/en/tutorials/workers/basics/)
40+
41+
For any question related to this article or Elektron WebSocket API page, please use the Developer Community [Q&A Forum](https://community.developers.thomsonreuters.com/).

app/market_price_app.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//******************************************************************************************/
2+
// The market_price_app.js is a main application file.
3+
// It handles all UI interactions.
4+
// It sends and receives messages with ws_workers.js file to communicate with ADS WebSocket.
5+
6+
// Author: Wasin Waeosri
7+
// Version: 1.0
8+
// Date: 7 November 2017
9+
//******************************************************************************************/
110
(function ($) {
211
//Define variables
312
var serverurl = '',
@@ -196,7 +205,7 @@
196205
wk.postMessage(pongObj);
197206

198207
//$('#commandsPre').html(`Sending Client Pong: ws.send(${JSON.stringify({ 'Type': 'Pong' }, undefined, 2)});`);
199-
$('#commandsPre').html('Sending Client Pong: ws.send(' + JSON.stringify({ 'Type': 'Pong' }, undefined, 2) + ');');
208+
$('#commandsPre').html('Sending Client Pong to Web Workers: WebWorkers.post(' + JSON.stringify({ 'Type': 'Pong' }, undefined, 2) + ');');
200209
}
201210

202211
//Send Login Close Request message to ADS WebSocket
@@ -215,7 +224,7 @@
215224
wk.postMessage(closeloginrequestObj);
216225

217226
//$('#commandsPre').html(`Sending Login Close Request: ws.send(${JSON.stringify(closeloginrequestMsg, undefined, 2)});`);
218-
$('#commandsPre').html('Sending Login Close Request: ws.send(' + JSON.stringify(closeloginrequestMsg, undefined, 2) + ');');
227+
$('#commandsPre').html('Sending Login Close Request to Web Workers: WebWorkers.post(' + JSON.stringify(closeloginrequestMsg, undefined, 2) + ');');
219228
}
220229

221230
})($);

app/ws_workers.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//******************************************************************************************/
2+
// The ws_workers.js is an application Web Workers file.
3+
// It handles all communications with ADS WebSocket.
4+
5+
// Author: Wasin Waeosri
6+
// Version: 1.0
7+
// Date: 7 November 2017
8+
//******************************************************************************************/
9+
110
(function () {
211

312
//Define WebSocket and protocol variables

0 commit comments

Comments
 (0)