@@ -1799,6 +1799,7 @@ TRestServer = class(TRest)
1799
1799
fServer: IRestOrmServer;
1800
1800
fRouter: TRestRouter;
1801
1801
fRouterSafe: TRWLightLock;
1802
+ fOnNotifyCallback: TOnRestServerClientCallback;
1802
1803
procedure SetNoAjaxJson (const Value : boolean);
1803
1804
function GetNoAjaxJson : boolean;
1804
1805
{ $ifdef HASINLINE} inline;{ $endif}
@@ -1817,6 +1818,7 @@ TRestServer = class(TRest)
1817
1818
function GetServiceMethodStat (const aMethod: RawUtf8): TSynMonitorInputOutput;
1818
1819
procedure SetRoutingClass (aServicesRouting: TRestServerUriContextClass);
1819
1820
procedure SetOptions (rso: TRestServerOptions);
1821
+ procedure SetOnNotifyCallback (const event: TOnRestServerClientCallback);
1820
1822
// / add a new session to the internal session list
1821
1823
// - do not use this method directly: this callback is to be used by
1822
1824
// TRestServerAuthentication* classes
@@ -1868,10 +1870,6 @@ TRestServer = class(TRest)
1868
1870
// - Ctxt is nil if the session is closed due to a timeout
1869
1871
// - Ctxt is not nil if the session is closed explicitly by the client
1870
1872
OnSessionClosed: TOnOrmSession;
1871
- // / this event will be executed to push notifications from the server to
1872
- // a remote client, using a (fake) interface parameter
1873
- // - is nil by default, but may point e.g. to TRestHttpServer.NotifyCallback
1874
- OnNotifyCallback: TOnRestServerClientCallback;
1875
1873
// / this event will be executed by TServiceFactoryServer.CreateInstance
1876
1874
// - you may set a callback to customize a server-side service instance,
1877
1875
// i.e. inject class-level dependencies:
@@ -1925,6 +1923,12 @@ TRestServer = class(TRest)
1925
1923
// - is set by default to PAGINGPARAMETERS_YAHOO constant by
1926
1924
// TRestServer.Create() constructor
1927
1925
UriPagingParameters: TRestServerUriPagingParameters;
1926
+ // / this event will be executed to push notifications from the WebSockets
1927
+ // server to a remote client, using a (fake) interface parameter
1928
+ // - is nil by default, but may point e.g. to TRestHttpServer.NotifyCallback
1929
+ // - only a single WS server can be assigned to a TRestServer instance
1930
+ property OnNotifyCallback: TOnRestServerClientCallback
1931
+ read fOnNotifyCallback write SetOnNotifyCallback;
1928
1932
1929
1933
// / Server initialization with a specified Database Model
1930
1934
// - if HandleUserAuthentication is false, will set URI access rights to
@@ -6687,6 +6691,16 @@ function TRestServer.GetServiceMethodStat(
6687
6691
result := nil ;
6688
6692
end ;
6689
6693
6694
+ procedure TRestServer.SetOnNotifyCallback (const event: TOnRestServerClientCallback);
6695
+ begin
6696
+ if Assigned(fOnNotifyCallback) and
6697
+ Assigned(event) then
6698
+ raise ERestException.CreateUtf8(
6699
+ ' %.OnNotifyCallback(%) set twice: only a single WS server can be assigned' ,
6700
+ [self, ClassNameShort(TObject(TMethod(event).Data))^]);
6701
+ fOnNotifyCallback := event;
6702
+ end ;
6703
+
6690
6704
procedure TRestServer.SetRoutingClass (
6691
6705
aServicesRouting: TRestServerUriContextClass);
6692
6706
begin
0 commit comments