author | Edouard Tisserant |
Thu, 19 Sep 2019 10:41:39 +0200 | |
branch | svghmi |
changeset 2781 | fbdd0fd8ee4f |
parent 2780 | e468f18df200 |
child 2783 | 5ee6967f721d |
permissions | -rw-r--r-- |
2780
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
1 |
(function(){ |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
2 |
var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws'); |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
3 |
var ws = new WebSocket(relative_URI); |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
4 |
ws.onmessage = function (evt) { |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
5 |
var received_msg = evt.data; |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
6 |
alert("Message is received..."+received_msg); |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
7 |
}; |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
8 |
ws.onopen = function (evt) { |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
9 |
ws.send("test"); |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
10 |
}; |
e468f18df200
SVGHMI: moved static JS code to a separate file included at xhtml generation time
Edouard Tisserant
parents:
diff
changeset
|
11 |
})(); |