Skip to content

Commit b44bb34

Browse files
WebSocket connection fail fix for Caché 2016.*.
1 parent d0b062c commit b44bb34

3 files changed

Lines changed: 64 additions & 38 deletions

File tree

export/WebTerminal/Installer.xml

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.1.1 (Build 505U)" ts="2015-12-20 14:44:54">
2+
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.2 (Build 559U)" ts="2016-02-06 20:50:57">
33
<Class name="WebTerminal.Installer">
44
<Description>
55
Importing this class will install Cache WEB Terminal properly.</Description>
66
<Super>%Projection.AbstractProjection</Super>
7-
<TimeChanged>63906,53063.112672</TimeChanged>
7+
<TimeChanged>63954,74786.153524</TimeChanged>
88
<TimeCreated>63890,71053.144208</TimeCreated>
99
<DependsOn>Common,Engine,Router,StaticContent</DependsOn>
1010

@@ -16,13 +16,60 @@ Importing this class will install Cache WEB Terminal properly.</Description>
1616
<Type>Installer</Type>
1717
</Projection>
1818

19+
<Method name="RegisterWebApplication">
20+
<ClassMethod>1</ClassMethod>
21+
<FormalSpec>name:%String,spec</FormalSpec>
22+
<Implementation><![CDATA[
23+
set ns = $NAMESPACE
24+
zn:ns'="%SYS" "%SYS"
25+
if ('##class(Security.Applications).Exists(name)) {
26+
w !, "Creating WEB application """_name_"""..."
27+
set tSC = ##class(Security.Applications).Create(name, .spec)
28+
if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
29+
w !, "WEB application """_name_""" is created."
30+
} else {
31+
do ##class(Security.Applications).Get(name, .props)
32+
if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
33+
w !, "WARNING! WEB application """_name_""" exists but does not refer to ",
34+
..#DispatchClass, ".", !,
35+
"Please, set correct dispatch class for this application ",
36+
"or create a terminal WEB-application manually."
37+
} else {
38+
w !, "WEB application """_name_""" already exists, so it should be ready to use. If not - remove this application manually and recompile."
39+
}
40+
}
41+
zn:ns'="%SYS" ns
42+
]]></Implementation>
43+
</Method>
44+
45+
<Method name="RemoveWebApplication">
46+
<ClassMethod>1</ClassMethod>
47+
<FormalSpec>name:%String</FormalSpec>
48+
<Implementation><![CDATA[
49+
set ns = $NAMESPACE
50+
zn:ns'="%SYS" "%SYS"
51+
if (##class(Security.Applications).Exists(name)) {
52+
do ##class(Security.Applications).Get(name, .props)
53+
if (props("DispatchClass") '= ..#DispatchClass) && (name = "/terminal") {
54+
w !, "Won't delete WEB-application """_name_""" because it does not refer to dispatch class anymore."
55+
} else {
56+
w !, "Deleting WEB application """_name_"""..."
57+
do ##class(Security.Applications).Delete(name)
58+
w !, "WEB application """_name_""" was successfully deleted."
59+
}
60+
}
61+
zn:ns'="%SYS" ns
62+
]]></Implementation>
63+
</Method>
64+
1965
<Method name="CreateProjection">
2066
<Description>
2167
This method is invoked when a class is compiled.</Description>
2268
<ClassMethod>1</ClassMethod>
2369
<FormalSpec><![CDATA[cls:%String,&params]]></FormalSpec>
2470
<ReturnType>%Status</ReturnType>
2571
<Implementation><![CDATA[
72+
write !, "Installing WebTerminal application to " _ $NAMESPACE
2673
set ns = $NAMESPACE // has to be package home namespace!
2774
zn:ns'="%SYS" "%SYS"
2875
do ##class(Security.System).GetInstallationSecuritySetting(.security)
@@ -31,22 +78,11 @@ This method is invoked when a class is compiled.</Description>
3178
set cspProperties("Description") = "A WEB application for Cache WEB Terminal."
3279
set cspProperties("IsNameSpaceDefault") = 0
3380
set cspProperties("DispatchClass") = ..#DispatchClass
34-
if ('##class(Security.Applications).Exists("/terminal")) {
35-
w !, "Creating WEB application ""/terminal""..."
36-
set tSC = ##class(Security.Applications).Create("/terminal", .cspProperties)
37-
if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
38-
w !, "WEB application ""/terminal"" is created."
39-
//set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
40-
} else {
41-
do ##class(Security.Applications).Get("/terminal", .props)
42-
if (props("DispatchClass") '= ..#DispatchClass) {
43-
w !, "WARNING! WEB application ""/terminal"" exists but does not refer to ",
44-
DispatchClass, ".", !, "Please, set correct dispatch class for this application ",
45-
"or create a terminal WEB-application manually."
46-
} else {
47-
w !, "WEB application ""/terminal"" already exists, so it is ready to use."
48-
}
49-
}
81+
do ..RegisterWebApplication("/terminal", .cspProperties)
82+
set cspProperties("AutheEnabled") = 64
83+
set cspProperties("Description") = "An application representing the open socket for /terminal application. Required since 2016.* Cache versions changed WebSocket behavior. PLEASE LEAVE THIS APPLICATION UNAUTHENTICATED, but do not worry: the socket won't accept anyone without the key."
84+
set cspProperties("DispatchClass") = ""
85+
do ..RegisterWebApplication("/terminalsocket", .cspProperties)
5086
set status = ##Class(Config.Namespaces).Get("%All")
5187
if ($$$ISERR(status)) { // no namespace %All
5288
w !, "Creating %All namespace..."
@@ -91,20 +127,11 @@ This method is invoked when a class is 'uncompiled'.</Description>
91127
<FormalSpec><![CDATA[cls:%String,&params,recompile:%Boolean]]></FormalSpec>
92128
<ReturnType>%Status</ReturnType>
93129
<Implementation><![CDATA[
130+
write !, "Uninstalling WebTerminal application from " _ $NAMESPACE
94131
set ns = $NAMESPACE // has to be package home namespace!
95132
zn:ns'="%SYS" "%SYS"
96-
if (##class(Security.Applications).Exists("/terminal")) {
97-
do ##class(Security.Applications).Get("/terminal", .props)
98-
if (props("DispatchClass") '= ..#DispatchClass) {
99-
w !, "Won't remove WEB-application ""/terminal"" because it does not refer to ",
100-
"dispatch class anymore."
101-
} else {
102-
w !, "Deleting WEB application ""/terminal""..."
103-
do ##class(Security.Applications).Delete("/terminal")
104-
kill ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass)
105-
w !, "WEB application ""/terminal"" was successfully removed."
106-
}
107-
}
133+
do ..RemoveWebApplication("/terminal")
134+
do ..RemoveWebApplication("/terminalsocket")
108135
w !, "Unmapping %WebTerminal package from all namespaces:"
109136
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
110137
set ptr = 0
@@ -124,4 +151,4 @@ This method is invoked when a class is 'uncompiled'.</Description>
124151
]]></Implementation>
125152
</Method>
126153
</Class>
127-
</Export>
154+
</Export>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"title": "Cache WEB Terminal",
44
"description": "Web-based terminal emulator for Caché administering.",
55
"author": "ZitRo",
6-
"version": "3.2.3",
7-
"releaseNumber": 21,
6+
"version": "3.2.4",
7+
"releaseNumber": 22,
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/intersystems-ru/webterminal.git"

webSource/js/CacheWebTerminalServer.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ var CacheWebTerminalServer = function (CONTROLLER, WS_PROTOCOL, IP, PORT) {
4545
*/
4646
this.socket = null;
4747

48+
this.CONNECTION_URL = this.PROTOCOL + "//" + this.IP + (this.PORT ? ":" + this.PORT : "")
49+
+ "/terminalsocket/" + encodeURIComponent(this.CACHE_CLASS_NAME);
50+
4851
this.initialize();
4952

5053
};
@@ -56,10 +59,7 @@ CacheWebTerminalServer.prototype.initialize = function () {
5659
var _this = this;
5760

5861
try {
59-
this.socket = new WebSocket(
60-
this.PROTOCOL + "//" + this.IP + (this.PORT ? ":" + this.PORT : "") + "/"
61-
+ encodeURIComponent(this.CACHE_CLASS_NAME)
62-
);
62+
this.socket = new WebSocket(this.CONNECTION_URL);
6363
} catch (e) {
6464
this.onError();
6565
console.error(e);
@@ -78,7 +78,6 @@ CacheWebTerminalServer.prototype.initialize = function () {
7878
};
7979

8080
this.socket.onmessage = function (event) {
81-
//console.log("server >> ", event.data);
8281
_this.CONTROLLER.serverData(event.data);
8382
};
8483

0 commit comments

Comments
 (0)