Skip to content

Commit

Permalink
Bump coco-gui version to 0.5.4 and add socket_host for WebSocket conn…
Browse files Browse the repository at this point in the history
…ections
  • Loading branch information
riccardodebenedictis committed Nov 19, 2024
1 parent 3de8e90 commit 17cbf4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion coco-gui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coco-gui",
"version": "0.5.3",
"version": "0.5.4",
"repository": {
"type": "git",
"url": "git+https://github.com/ratioSolver/cocoGUI.git"
Expand Down
6 changes: 4 additions & 2 deletions coco-gui/src/coco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export namespace coco {
user_type: taxonomy.Type | null = null;
user: (taxonomy.Item & { personal_data: Record<string, any> }) | null = null;
host: string = 'http://localhost:8080';
socket_host: string = 'ws://localhost:8080';
auth: boolean = false;
types: Map<string, taxonomy.Type>;
items: Map<string, taxonomy.Item>;
Expand Down Expand Up @@ -89,6 +90,7 @@ export namespace coco {
*/
init(host: string = 'localhost', port: number = 8080, ssl: boolean = false, auth: boolean = false): void {
this.host = (ssl ? 'https' : 'http') + '://' + host + ':' + port;
this.socket_host = (ssl ? 'wss' : 'ws') + '://' + host + ':' + port;
console.log('CoCo server:', this.host);
this.auth = auth;
console.log('Authentication:', this.auth);
Expand Down Expand Up @@ -347,8 +349,8 @@ export namespace coco {
* @param timeout The timeout value in milliseconds for reconnecting to the server if the connection is closed. Default is 5000.
*/
connect(token: string | null = null, timeout = 5000) {
console.debug('Connecting to CoCo server ' + this.host + '/coco');
this.socket = new WebSocket(this.host + '/coco');
console.debug('Connecting to CoCo server ' + this.socket_host + '/coco');
this.socket = new WebSocket(this.socket_host + '/coco');
this.socket.onopen = () => {
console.debug('Connected to CoCo server');
if (token) {
Expand Down

0 comments on commit 17cbf4f

Please sign in to comment.