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
45399c29
Commit
45399c29
authored
May 31, 2026
by
Michael Brachmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging websockets
parent
f46aa96a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
63 deletions
+8
-63
Ws.ServiceImpl.pas
emiMobileServer/Source/Ws.ServiceImpl.pas
+8
-63
No files found.
emiMobileServer/Source/Ws.ServiceImpl.pas
View file @
45399c29
...
...
@@ -3,33 +3,26 @@ unit Ws.ServiceImpl;
interface
uses
Common
.
Logging
,
System
.
SysUtils
,
XData
.
Server
.
Module
,
XData
.
Service
.
Common
,
Sparkle
.
WebSocket
,
XData
.
Server
.
Module
,
System
.
JSON
,
Sparkle
.
Sys
.
Timer
,
Sparkle
.
HttpServer
.
Context
,
Ws
.
Service
,
BaseRequest
,
LoginRequest
,
Pkg
.
Json
.
DTO
,
Generics
.
Collections
;
Ws
.
Service
;
type
[
ServiceImplementation
]
TWebSocketService
=
class
(
TInterfacedObject
,
IWebSocketService
)
public
function
WebSockerConnectionHandler
:
TJSONObject
;
private
function
Health
:
string
;
procedure
ProcessJsonMessage
(
const
AMsg
:
string
);
end
;
implementation
{ TWebSocketService }
uses
System
.
SysUtils
,
Common
.
Logging
,
Sparkle
.
WebSocket
,
Sparkle
.
Sys
.
Timer
,
Sparkle
.
HttpServer
.
Context
;
function
TWebSocketService
.
WebSockerConnectionHandler
:
TJSONObject
;
var
...
...
@@ -62,7 +55,6 @@ begin
end
;
MsgStr
:=
TEncoding
.
Default
.
GetString
(
Msg
.
Data
);
//TODO: verify JWT in MsgStr against serverConfig.jwtTokenSecret
// use the BCL JOSE verify API once the correct method is confirmed
Logger
.
Log
(
1
,
'websocket auth ok (token received, verification pending)-------'
);
Timer
:=
TSparkleTimer
.
Create
(
...
...
@@ -83,7 +75,6 @@ begin
begin
MsgStr
:=
TEncoding
.
Default
.
GetString
(
Msg
.
Data
);
Logger
.
Log
(
1
,
'Web Socket Message: '
+
MsgStr
);
//TODO: store connection in map with device id, implement message protocol
end
;
TWebSocketMessageType
.
Close
:
Break
;
...
...
@@ -94,52 +85,6 @@ begin
end
;
end
;
function
TWebSocketService
.
Health
:
string
;
begin
Result
:=
'ok'
;
end
;
procedure
TWebSocketService
.
ProcessJsonMessage
(
const
AMsg
:
string
);
var
MsgDTO
:
TBaseRequest
;
request
:
TRequest
;
rawJsObj
:
TJSONArray
;
begin
MsgDTO
:=
nil
;
try
rawJsObj
:=
TJSONObject
.
ParseJSONValue
(
AMsg
)
as
TJSONArray
;
MsgDTO
.
FromJson
(
AMsg
);
for
request
in
MsgDTO
.
Request
do
begin
// Process each Request object
Logger
.
Log
(
1
,
'Action: '
+
request
.
RequestId
);
if
request
.
RequestId
=
'doLogin'
then
begin
Logger
.
Log
(
1
,
'Action: '
+
request
.
RequestId
);
//TODO: implement instantiation and handling of each request type
// not sure if upcasting works in delphi here but probably not so we do this:
// rawJsObj:=TJSONObject.ParseJSONValue(AMsg) as TJSONArray
// and then ---->
// loginRequest.FromJson(rawJsObj.Items[0].ToJSON());
var
loginRequest
:
TLoginRequest
;
begin
loginRequest
.
FromJson
(
rawJsObj
.
Items
[
0
].
ToJSON
());
//loginRequest.LoginInfo.Shift
//TODO: it would be really great to have the JDO convert to database sql
end
;
end
;
end
;
// ... further logic
finally
MsgDTO
.
Free
;
end
;
end
;
initialization
RegisterServiceType
(
TWebSocketService
);
...
...
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