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
5cc2b73b
Commit
5cc2b73b
authored
Mar 10, 2026
by
emsys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
websocket wired up in client. ws client connection error.
parent
80ed6f36
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
15 deletions
+136
-15
emiMobile.groupproj
emiMobile.groupproj
+48
-0
Ws.Server.Module.dfm
emiMobileServer/Source/Ws.Server.Module.dfm
+2
-0
Ws.ServiceImpl.pas
emiMobileServer/Source/Ws.ServiceImpl.pas
+9
-4
emiMobileServer.ini
emiMobileServer/bin/emiMobileServer.ini
+1
-1
Module.Websocket.dfm
webEMIMobile/Module.Websocket.dfm
+13
-2
Module.Websocket.pas
webEMIMobile/Module.Websocket.pas
+49
-6
View.Main.pas
webEMIMobile/View.Main.pas
+7
-1
webEmiMobile.dpr
webEMIMobile/webEmiMobile.dpr
+2
-1
webEmiMobile.dproj
webEMIMobile/webEmiMobile.dproj
+5
-0
No files found.
emiMobile.groupproj
0 → 100644
View file @
5cc2b73b
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{012E57DC-0378-4E45-B2F6-DFA72B2D10B1}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Projects Include="emiMobileServer\emiMobileServer.dproj">
<Dependencies/>
</Projects>
<Projects Include="webEMIMobile\webEmiMobile.dproj">
<Dependencies/>
</Projects>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Default.Personality/>
</BorlandProject>
</ProjectExtensions>
<Target Name="emiMobileServer">
<MSBuild Projects="emiMobileServer\emiMobileServer.dproj"/>
</Target>
<Target Name="emiMobileServer:Clean">
<MSBuild Projects="emiMobileServer\emiMobileServer.dproj" Targets="Clean"/>
</Target>
<Target Name="emiMobileServer:Make">
<MSBuild Projects="emiMobileServer\emiMobileServer.dproj" Targets="Make"/>
</Target>
<Target Name="webEmiMobile">
<MSBuild Projects="webEMIMobile\webEmiMobile.dproj"/>
</Target>
<Target Name="webEmiMobile:Clean">
<MSBuild Projects="webEMIMobile\webEmiMobile.dproj" Targets="Clean"/>
</Target>
<Target Name="webEmiMobile:Make">
<MSBuild Projects="webEMIMobile\webEmiMobile.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="emiMobileServer;webEmiMobile"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="emiMobileServer:Clean;webEmiMobile:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="emiMobileServer:Make;webEmiMobile:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>
emiMobileServer/Source/Ws.Server.Module.dfm
View file @
5cc2b73b
...
...
@@ -27,6 +27,8 @@ object WsServerModule: TWsServerModule
OnGetSecret = XDataServer1JWTGetSecret
end
object XDataServer1WebSocket: TSparkleWebSocketMiddleware
AllowedOrigins.Strings = (
'*')
end
end
end
emiMobileServer/Source/Ws.ServiceImpl.pas
View file @
5cc2b73b
...
...
@@ -3,6 +3,7 @@ unit Ws.ServiceImpl;
interface
uses
Common
.
Logging
,
System
.
SysUtils
,
XData
.
Server
.
Module
,
XData
.
Service
.
Common
,
...
...
@@ -37,6 +38,8 @@ var
JSONObject
:
TJSONObject
;
MsgStr
:
string
;
begin
Logger
.
Log
(
1
,
'websocket begin-------'
);
// Check if the client sent an websocket request, if yes the IWebSocketUpgrader interface will be available.
Upgrader
:=
THttpServerContext
.
Current
.
Item
<
IWebSocketUpgrader
>;
if
Upgrader
=
nil
then
...
...
@@ -44,10 +47,12 @@ begin
TXDataOperationContext
.
Current
.
Handler
.
SetStatusCode
(
400
);
Exit
;
end
;
Logger
.
Log
(
1
,
'websocket upgrading-------'
);
// Upgrade to websocket
WebSocket
:=
Upgrader
.
Upgrade
;
Logger
.
Log
(
1
,
'websocket upgraded-------'
);
// Send a message to client every 2 seconds
Timer
:=
TSparkleTimer
.
Create
(
procedure
(
Value
:
TObject
)
...
...
@@ -65,12 +70,12 @@ begin
Msg
:=
WebSocket
.
Receive
;
case
Msg
.
MessageType
of
TWebSocketMessageType
.
Text
:
Logger
.
Log
(
1
,
'Web Socket Message: '
+
MsgStr
);
//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,
// probably store the websocket connection in a map with device id or some other uuid
self
.
ProcessJsonMessage
(
MsgStr
);
//
self.ProcessJsonMessage(MsgStr);
//TWebSocketMessageType.Close:
// WebSocket.SendClose(WebSocketStatusCodes.NormalClosure);
end
;
...
...
@@ -94,10 +99,10 @@ begin
for
request
in
MsgDTO
.
Request
do
begin
// Process each Request object
Writeln
(
'Action: '
+
request
.
RequestId
);
Logger
.
Log
(
1
,
'Action: '
+
request
.
RequestId
);
if
request
.
RequestId
=
'doLogin'
then
begin
Writeln
(
'Action: '
+
request
.
RequestId
);
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
...
...
emiMobileServer/bin/emiMobileServer.ini
View file @
5cc2b73b
[Settings]
LogFileNum
=
6
52
LogFileNum
=
6
77
webClientVersion
=
0.1.0
webEMIMobile/Module.Websocket.dfm
View file @
5cc2b73b
object
DataModule1: TDataModule1
object
dmWebsocket: TdmWebsocket
Height = 480
Width = 640
object WebSocketClient1: TWebSocketClient
object EMiMobileWebSocketClient: TWebSocketClient
UseSSL = True
Port = 443
HostName = 'webapps.em-sys.net'
PathName = '/emiMobile/ws/emimobile'
Protocols.Strings = (
'WEB')
OnConnect = EMiMobileWebSocketClientConnect
OnBinaryDataReceived = EMiMobileWebSocketClientBinaryDataReceived
OnDisconnect = EMiMobileWebSocketClientDisconnect
OnDataReceived = EMiMobileWebSocketClientDataReceived
OnMessageReceived = EMiMobileWebSocketClientMessageReceived
Left = 218
Top = 130
end
...
...
webEMIMobile/Module.Websocket.pas
View file @
5cc2b73b
...
...
@@ -3,19 +3,29 @@ unit Module.Websocket;
interface
uses
System
.
SysUtils
,
System
.
Classes
,
WEBLib
.
WebSocketClient
;
System
.
SysUtils
,
System
.
Classes
,
WEBLib
.
WebSocketClient
,
Web
,
WEBLib
.
Controls
,
WEBLib
.
Modules
;
type
T
DataModule1
=
class
(
T
DataModule
)
WebSocketClient1
:
TWebSocketClient
;
T
dmWebsocket
=
class
(
TWeb
DataModule
)
private
{ Private declarations }
procedure
EMiMobileWebSocketClientConnect
(
Sender
:
TObject
);
procedure
EMiMobileWebSocketClientDataReceived
(
Sender
:
TObject
;
Origin
:
string
;
SocketData
:
TJSObjectRecord
);
procedure
EMiMobileWebSocketClientDisconnect
(
Sender
:
TObject
);
procedure
EMiMobileWebSocketClientMessageReceived
(
Sender
:
TObject
;
AMessage
:
string
);
procedure
EMiMobileWebSocketClientBinaryDataReceived
(
Sender
:
TObject
;
AData
:
TBytes
);
public
{ Public declarations }
EMiMobileWebSocketClient
:
TWebSocketClient
;
procedure
DataModuleCreate
(
Sender
:
TObject
);
end
;
var
DataModule1
:
TDataModule1
;
dmWebsocket
:
TdmWebsocket
;
implementation
...
...
@@ -23,4 +33,37 @@ implementation
{$R *.dfm}
procedure
TdmWebsocket
.
DataModuleCreate
(
Sender
:
TObject
);
begin
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientBinaryDataReceived
(
Sender
:
TObject
;
AData
:
TBytes
);
begin
console
.
log
(
'EMiMobileWebSocketClientBinaryDataReceived'
);
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientConnect
(
Sender
:
TObject
);
begin
console
.
log
(
'EMiMobileWebSocketClientConnect'
);
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientDataReceived
(
Sender
:
TObject
;
Origin
:
string
;
SocketData
:
TJSObjectRecord
);
begin
console
.
log
(
'EMiMobileWebSocketClientDataReceived'
);
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientDisconnect
(
Sender
:
TObject
);
begin
console
.
log
(
'EMiMobileWebSocketClientDisconnect'
);
end
;
procedure
TdmWebsocket
.
EMiMobileWebSocketClientMessageReceived
(
Sender
:
TObject
;
AMessage
:
string
);
begin
console
.
log
(
'EMiMobileWebSocketClientMessageReceived'
);
end
;
end
.
webEMIMobile/View.Main.pas
View file @
5cc2b73b
...
...
@@ -6,7 +6,8 @@ uses
System
.
SysUtils
,
System
.
Classes
,
JS
,
Web
,
WEBLib
.
Graphics
,
WEBLib
.
Controls
,
WEBLib
.
Forms
,
WEBLib
.
Dialogs
,
WEBLib
.
ExtCtrls
,
Vcl
.
Controls
,
Vcl
.
StdCtrls
,
WEBLib
.
StdCtrls
,
Data
.
DB
,
XData
.
Web
.
JsonDataset
,
XData
.
Web
.
Dataset
,
App
.
Types
,
ConnectionModule
,
XData
.
Web
.
Client
,
View
.
Map
,
View
.
Units
,
View
.
Complaints
;
App
.
Types
,
ConnectionModule
,
XData
.
Web
.
Client
,
View
.
Map
,
View
.
Units
,
View
.
Complaints
,
Module
.
Websocket
;
type
TFViewMain
=
class
(
TWebForm
)
...
...
@@ -48,6 +49,7 @@ type
FComplaintsForm
:
TFViewComplaints
;
FDetailsForm
:
TWebForm
;
FLogoutProc
:
TLogoutProc
;
//WebSocketModule: Module.Websocket;
[
async
]
procedure
RefreshBadgesAsync
;
procedure
ShowUnitDetails
(
UnitId
:
string
);
procedure
SetHeaderTitle
(
const
title
:
string
);
...
...
@@ -137,6 +139,9 @@ begin
SetActivePanel
(
apMap
);
RefreshBadgesAsync
;
dmWebsocket
:=
TdmWebsocket
.
Create
(
Self
);
dmWebsocket
.
EMiMobileWebSocketClient
.
Active
:=
True
;
end
;
...
...
@@ -411,6 +416,7 @@ begin
end
;
procedure
TFViewMain
.
tmrGlobalRefreshTimer
(
Sender
:
TObject
);
begin
Inc
(
FGlobalRefreshTick
);
...
...
webEMIMobile/webEmiMobile.dpr
View file @
5cc2b73b
...
...
@@ -24,7 +24,8 @@ uses
View.ComplaintDetails in 'View.ComplaintDetails.pas' {FViewComplaintDetails: TWebForm} {*.html},
View.UnitDetails in 'View.UnitDetails.pas' {FViewUnitDetails: TWebForm} {*.html},
uMapFilters in 'uMapFilters.pas',
View.ComplaintArchive in 'View.ComplaintArchive.pas' {FViewComplaintArchive: TWebForm} {*.html};
View.ComplaintArchive in 'View.ComplaintArchive.pas' {FViewComplaintArchive: TWebForm} {*.html},
Module.Websocket in 'Module.Websocket.pas' {dmWebsocket: TDataModule};
{$R *.res}
...
...
webEMIMobile/webEmiMobile.dproj
View file @
5cc2b73b
...
...
@@ -194,6 +194,11 @@
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="Module.Websocket.pas">
<Form>dmWebsocket</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
<None Include="index.html"/>
<None Include="css\app.css"/>
<None Include="css\spinner.css"/>
...
...
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