@@ -238,8 +238,8 @@ TSocketsIOClient = class(TEngineIOAbstract)
238
238
procedure AfterOpen (OpenPayload: PUtf8Char);
239
239
// handle server response after namespace connection request
240
240
procedure AfterNamespaceConnect (const Response: TSocketIOMessage);
241
- procedure OnEvent (const aMessage: TSocketIOMessage);
242
- procedure OnAck (const Message: TSocketIOMessage);
241
+ procedure OnEvent (const aMessage: TSocketIOMessage); virtual ;
242
+ procedure OnAck (const Message: TSocketIOMessage); virtual ;
243
243
public
244
244
// / low-level client WebSockets connection factory for host and port
245
245
// - calls THttpClientWebSockets.WebSocketsConnect for the Socket.IO protocol
@@ -276,9 +276,11 @@ TSocketsIOClient = class(TEngineIOAbstract)
276
276
const Callback: TOnSocketIOEvent);
277
277
// / register all published methods of a class as local namespace handlers
278
278
// - published method names are case-sensitive Socket.IO event names
279
+ // - if no Instance is supplied, will register self published methods
279
280
// - the methods should follow the TOnSocketIOMethod exact signature, i.e.
280
- // ! procedure eventname(const Data: TDocVariantData);
281
- procedure LocalPublishedMethods (const Namespace: RawUtf8; Instance: TObject);
281
+ // ! function eventname(const Data: TDocVariantData): RawJson;
282
+ procedure LocalPublishedMethods (const Namespace: RawUtf8;
283
+ Instance: TObject = nil );
282
284
// / access to a given Socket.IO namespace
283
285
// - sends a connect message if needed (for first-time registration)
284
286
function Connect (const NameSpace: RawUtf8; const Data: RawUtf8 = ' ' ;
@@ -854,8 +856,9 @@ procedure TSocketsIOClient.LocalEvent(
854
856
procedure TSocketsIOClient.LocalPublishedMethods (
855
857
const Namespace: RawUtf8; Instance: TObject);
856
858
begin
857
- if Instance <> nil then
858
- Local(NameSpace).RegisterPublishedMethods(Instance);
859
+ if Instance = nil then
860
+ Instance := self;
861
+ Local(NameSpace).RegisterPublishedMethods(Instance);
859
862
end ;
860
863
861
864
function TSocketsIOClient.RemoteNames : TRawUtf8DynArray;
0 commit comments