Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emiMobile
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mac Stephens
emiMobile
Commits
f6babd1d
Commit
f6babd1d
authored
May 06, 2026
by
Michael Brachmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on websocket communication and routing issue
parent
5cc2b73b
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
8 deletions
+72
-8
Ws.Service.pas
emiMobileServer/Source/Ws.Service.pas
+1
-2
Ws.ServiceImpl.pas
emiMobileServer/Source/Ws.ServiceImpl.pas
+3
-0
App.Config.pas
webEMIMobile/App.Config.pas
+6
-0
ConnectionModule.pas
webEMIMobile/ConnectionModule.pas
+5
-0
Module.Websocket.dfm
webEMIMobile/Module.Websocket.dfm
+1
-2
Module.Websocket.pas
webEMIMobile/Module.Websocket.pas
+51
-0
View.Main.pas
webEMIMobile/View.Main.pas
+3
-3
config.json
webEMIMobile/config/config.json
+2
-1
No files found.
emiMobileServer/Source/Ws.Service.pas
View file @
f6babd1d
...
...
@@ -9,8 +9,7 @@ const
WS_MODEL
=
'Ws'
;
type
[
ServiceContract
]
[
Route
(
'ws'
)]
[
ServiceContract
,
Model
(
WS_MODEL
)]
IWebSocketService
=
interface
(
IInvokable
)
[
'{673FE678-D9EF-468D-89CB-CEF26E8758BC}'
]
[
HttpGet
,
Route
(
'emimobile'
)]
...
...
emiMobileServer/Source/Ws.ServiceImpl.pas
View file @
f6babd1d
...
...
@@ -70,7 +70,10 @@ begin
Msg
:=
WebSocket
.
Receive
;
case
Msg
.
MessageType
of
TWebSocketMessageType
.
Text
:
begin
MsgStr
:=
Msg
.
AsText
;
Logger
.
Log
(
1
,
'Web Socket Message: '
+
MsgStr
);
end
;
//TODO: HERE we need to create a map to store connections for later
// and implement protocol to communicate
// store websocket obj, handle another layer of compression/encryption,
...
...
webEMIMobile/App.Config.pas
View file @
f6babd1d
...
...
@@ -14,11 +14,13 @@ type
FAuthUrl
:
string
;
FApiUrl
:
string
;
FAppUrl
:
string
;
FWsUrl
:
string
;
public
constructor
Create
;
property
AuthUrl
:
string
read
FAuthUrl
write
FAuthUrl
;
property
ApiUrl
:
string
read
FApiUrl
write
FApiUrl
;
property
AppUrl
:
string
read
FAppUrl
write
FAppUrl
;
property
WsUrl
:
string
read
FWsUrl
write
FWsUrl
;
end
;
TConfigLoadedProc
=
reference
to
procedure
(
Config
:
TAppConfig
);
...
...
@@ -49,6 +51,9 @@ procedure LoadConfig(LoadProc: TConfigLoadedProc);
if
JS
.
toString
(
Obj
[
'AppUrl'
])
<>
''
then
Config
.
AppUrl
:=
JS
.
toString
(
Obj
[
'AppUrl'
]);
if
JS
.
toString
(
Obj
[
'WsUrl'
])
<>
''
then
Config
.
WsUrl
:=
JS
.
toString
(
Obj
[
'WsUrl'
]);
end
;
finally
LoadProc
(
Config
);
...
...
@@ -86,6 +91,7 @@ begin
FAuthUrl
:=
''
;
FApiUrl
:=
''
;
FAppUrl
:=
''
;
FWsUrl
:=
''
;
end
;
end
.
webEMIMobile/ConnectionModule.pas
View file @
f6babd1d
...
...
@@ -17,7 +17,9 @@ type
procedure
AuthConnectionError
(
Error
:
TXDataWebConnectionError
);
private
FUnauthorizedAccessProc
:
TUnauthorizedAccessProc
;
FWsUrl
:
string
;
public
property
WsUrl
:
string
read
FWsUrl
;
const
clientVersion
=
'0.1.0'
;
procedure
InitApp
(
SuccessProc
:
TSuccessProc
;
UnauthorizedAccessProc
:
TUnauthorizedAccessProc
);
...
...
@@ -74,6 +76,9 @@ procedure TDMConnection.InitApp(SuccessProc: TSuccessProc;
if
Config
.
ApiUrl
<>
''
then
ApiConnection
.
URL
:=
Config
.
ApiUrl
;
if
Config
.
WsUrl
<>
''
then
FWsUrl
:=
Config
.
WsUrl
;
AuthConnection
.
Open
(
SuccessProc
);
end
;
...
...
webEMIMobile/Module.Websocket.dfm
View file @
f6babd1d
...
...
@@ -6,8 +6,7 @@ object dmWebsocket: TdmWebsocket
Port = 443
HostName = 'webapps.em-sys.net'
PathName = '/emiMobile/ws/emimobile'
Protocols.Strings = (
'WEB')
Protocols.Strings = ()
OnConnect = EMiMobileWebSocketClientConnect
OnBinaryDataReceived = EMiMobileWebSocketClientBinaryDataReceived
OnDisconnect = EMiMobileWebSocketClientDisconnect
...
...
webEMIMobile/Module.Websocket.pas
View file @
f6babd1d
...
...
@@ -21,6 +21,7 @@ type
public
EMiMobileWebSocketClient
:
TWebSocketClient
;
procedure
DataModuleCreate
(
Sender
:
TObject
);
procedure
Connect
(
const
AWsUrl
:
string
);
end
;
...
...
@@ -38,6 +39,56 @@ begin
end
;
procedure
TdmWebsocket
.
Connect
(
const
AWsUrl
:
string
);
var
Rest
,
HostPort
,
Scheme
:
string
;
ColonSlashSlash
,
SlashPos
,
ColonPos
:
Integer
;
begin
if
AWsUrl
=
''
then
Exit
;
// Parse ws://host:port/path or wss://host:port/path
ColonSlashSlash
:=
Pos
(
'://'
,
AWsUrl
);
if
ColonSlashSlash
=
0
then
Exit
;
Scheme
:=
LowerCase
(
Copy
(
AWsUrl
,
1
,
ColonSlashSlash
-
1
));
Rest
:=
Copy
(
AWsUrl
,
ColonSlashSlash
+
3
,
MaxInt
);
SlashPos
:=
Pos
(
'/'
,
Rest
);
if
SlashPos
>
0
then
begin
HostPort
:=
Copy
(
Rest
,
1
,
SlashPos
-
1
);
EMiMobileWebSocketClient
.
PathName
:=
Copy
(
Rest
,
SlashPos
,
MaxInt
);
end
else
begin
HostPort
:=
Rest
;
EMiMobileWebSocketClient
.
PathName
:=
'/'
;
end
;
ColonPos
:=
Pos
(
':'
,
HostPort
);
if
ColonPos
>
0
then
begin
EMiMobileWebSocketClient
.
HostName
:=
Copy
(
HostPort
,
1
,
ColonPos
-
1
);
if
Scheme
=
'wss'
then
EMiMobileWebSocketClient
.
Port
:=
StrToIntDef
(
Copy
(
HostPort
,
ColonPos
+
1
,
MaxInt
),
443
)
else
EMiMobileWebSocketClient
.
Port
:=
StrToIntDef
(
Copy
(
HostPort
,
ColonPos
+
1
,
MaxInt
),
80
);
end
else
begin
EMiMobileWebSocketClient
.
HostName
:=
HostPort
;
if
Scheme
=
'wss'
then
EMiMobileWebSocketClient
.
Port
:=
443
else
EMiMobileWebSocketClient
.
Port
:=
80
;
end
;
EMiMobileWebSocketClient
.
UseSSL
:=
(
Scheme
=
'wss'
);
EMiMobileWebSocketClient
.
Active
:=
True
;
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientBinaryDataReceived
(
Sender
:
TObject
;
AData
:
TBytes
);
begin
...
...
webEMIMobile/View.Main.pas
View file @
f6babd1d
...
...
@@ -141,7 +141,7 @@ begin
RefreshBadgesAsync
;
dmWebsocket
:=
TdmWebsocket
.
Create
(
Self
);
dmWebsocket
.
EMiMobileWebSocketClient
.
Active
:=
True
;
dmWebsocket
.
Connect
(
DMConnection
.
WsUrl
)
;
end
;
...
...
@@ -445,9 +445,9 @@ begin
on
E
:
Exception
do
begin
el
:=
Document
.
getElementById
(
'view.main.badgecomplaints'
);
if
Assigned
(
el
)
then
TJSHtmlElement
(
el
).
innerText
:=
''
;
if
Assigned
(
el
)
then
TJSHtmlElement
(
el
).
innerText
:=
'
�
'
;
el
:=
Document
.
getElementById
(
'view.main.badgeunits'
);
if
Assigned
(
el
)
then
TJSHtmlElement
(
el
).
innerText
:=
''
;
if
Assigned
(
el
)
then
TJSHtmlElement
(
el
).
innerText
:=
'
�
'
;
Console
.
Log
(
'Badge refresh error: '
+
E
.
Message
);
end
;
end
;
...
...
webEMIMobile/config/config.json
View file @
f6babd1d
{
"AuthUrl"
:
"http://localhost:2009/emimobile/auth/"
,
"ApiUrl"
:
"http://localhost:2009/emimobile/api/"
,
"AppUrl"
:
"http://localhost:2009/emimobile/app/"
"AppUrl"
:
"http://localhost:2009/emimobile/app/"
,
"WsUrl"
:
"ws://localhost:2009/emiMobile/ws/emimobile"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment