@magic-xpa/utils 4.1300.0-dev4130.117 → 4.1300.0-dev4130.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  import { Encoding, StringBuilder, Hashtable, Stack, NChar, NNumber, NString, RefParam, isNullOrUndefined, DateTime, ISO_8859_1_Encoding, ApplicationException, Int32, Exception, List, Thread, Debug } from '@magic-xpa/mscorelib';
2
2
  import { XMLParser } from 'fast-xml-parser';
3
+ import { io } from 'socket.io-client';
4
+ import { Subject } from 'rxjs';
5
+ import { filter } from 'rxjs/operators';
3
6
 
4
7
  /// <summary>JPN: DBCS support
5
8
  /// Utility Class for String
@@ -5770,6 +5773,150 @@ class StorageAttributeCheck {
5770
5773
  }
5771
5774
  }
5772
5775
 
5776
+ class SubscriberClient {
5777
+ static instance;
5778
+ socket;
5779
+ subscribedTopics = new Set();
5780
+ messageSubject = new Subject();
5781
+ subscriptionsDataSubject = new Subject();
5782
+ constructor() {
5783
+ // Connect to the Socket.IO server with subscriber role
5784
+ this.socket = io('http://localhost:3000', {
5785
+ query: {
5786
+ role: 'subscriber',
5787
+ token: 'abc123' // Default token for testing; replace with actual authentication
5788
+ }
5789
+ });
5790
+ // Handle connection
5791
+ this.socket.on('connect', () => {
5792
+ console.log('Connected to server as subscriber:', this.socket.id);
5793
+ });
5794
+ // Handle disconnection
5795
+ this.socket.on('disconnect', () => {
5796
+ console.log('Disconnected from server');
5797
+ this.subscribedTopics.clear();
5798
+ });
5799
+ // Handle subscription confirmation
5800
+ this.socket.on('subscribed', (data) => {
5801
+ this.subscribedTopics.add(data.topic);
5802
+ console.log('Subscribed to topic:', data.topic, data.message);
5803
+ });
5804
+ // Handle unsubscription confirmation
5805
+ this.socket.on('unsubscribed', (data) => {
5806
+ this.subscribedTopics.delete(data.topic);
5807
+ console.log('Unsubscribed from topic:', data.topic, data.message);
5808
+ });
5809
+ // Handle errors
5810
+ this.socket.on('error', (error) => {
5811
+ console.error('Socket error:', error.message);
5812
+ });
5813
+ // Handle incoming messages
5814
+ this.socket.on('message', (data) => {
5815
+ this.messageSubject.next(data);
5816
+ });
5817
+ // Handle subscriptions data
5818
+ this.socket.on('subscriptionsData', (data) => {
5819
+ this.subscriptionsDataSubject.next(data);
5820
+ });
5821
+ }
5822
+ /**
5823
+ * Get the singleton instance of SubscriberClient
5824
+ */
5825
+ static getInstance() {
5826
+ if (!SubscriberClient.instance) {
5827
+ SubscriberClient.instance = new SubscriberClient();
5828
+ }
5829
+ return SubscriberClient.instance;
5830
+ }
5831
+ /**
5832
+ * Subscribe to a specific topic
5833
+ * @param topic The topic to subscribe to
5834
+ */
5835
+ subscribe(topic) {
5836
+ if (!this.subscribedTopics.has(topic)) {
5837
+ this.socket.emit('subscribe', topic);
5838
+ }
5839
+ }
5840
+ /**
5841
+ * Subscribe to multiple topics at once
5842
+ * @param topics Array of topics to subscribe to
5843
+ */
5844
+ subscribeToTopics(topics) {
5845
+ topics.forEach(topic => this.subscribe(topic));
5846
+ }
5847
+ /**
5848
+ * Unsubscribe from a specific topic
5849
+ * @param topic The topic to unsubscribe from
5850
+ */
5851
+ unsubscribe(topic) {
5852
+ if (this.subscribedTopics.has(topic)) {
5853
+ this.socket.emit('unsubscribe', topic);
5854
+ }
5855
+ }
5856
+ /**
5857
+ * Unsubscribe from multiple topics at once
5858
+ * @param topics Array of topics to unsubscribe from
5859
+ */
5860
+ unsubscribeFromTopics(topics) {
5861
+ topics.forEach(topic => this.unsubscribe(topic));
5862
+ }
5863
+ /**
5864
+ * Unsubscribe from all topics
5865
+ */
5866
+ unsubscribeFromAll() {
5867
+ this.subscribedTopics.forEach(topic => this.unsubscribe(topic));
5868
+ }
5869
+ /**
5870
+ * Check if subscribed to a specific topic
5871
+ * @param topic The topic to check
5872
+ * @returns true if subscribed, false otherwise
5873
+ */
5874
+ isSubscribed(topic) {
5875
+ return this.subscribedTopics.has(topic);
5876
+ }
5877
+ /**
5878
+ * Get all currently subscribed topics
5879
+ * @returns Array of subscribed topics
5880
+ */
5881
+ getSubscribedTopics() {
5882
+ return Array.from(this.subscribedTopics);
5883
+ }
5884
+ /**
5885
+ * Get an Observable for incoming messages from all subscribed topics
5886
+ * @returns Observable that emits message data
5887
+ */
5888
+ onMessage() {
5889
+ return this.messageSubject.asObservable();
5890
+ }
5891
+ /**
5892
+ * Get an Observable for incoming messages from a specific topic
5893
+ * @param topic The topic to filter messages for
5894
+ * @returns Observable that emits message data for the specified topic
5895
+ */
5896
+ onMessageForTopic(topic) {
5897
+ return this.messageSubject.asObservable().pipe(filter((data) => data.topic === topic));
5898
+ }
5899
+ /**
5900
+ * Get current subscriptions (for debugging)
5901
+ */
5902
+ getSubscriptions() {
5903
+ this.socket.emit('getSubscriptions');
5904
+ }
5905
+ /**
5906
+ * Listen for subscriptions data
5907
+ * @returns Observable that emits subscriptions list
5908
+ */
5909
+ onSubscriptionsData() {
5910
+ return this.subscriptionsDataSubject.asObservable();
5911
+ }
5912
+ /**
5913
+ * Disconnect from the server
5914
+ */
5915
+ disconnect() {
5916
+ this.socket.disconnect();
5917
+ }
5918
+ }
5919
+
5773
5920
  /// <summary>
5774
5921
  /// Helper class for synchronized execution.
5775
5922
  /// It works by creating a promise and then waiting for the promise to be completed
@@ -6492,5 +6639,5 @@ class XmlParser {
6492
6639
  * Generated bundle index. Do not edit.
6493
6640
  */
6494
6641
 
6495
- export { APGDisplayMode, APGFormSize, APGInvokedFrom, APGMode, APGOption, APGType, Access, AlignmentTypeHori, AlignmentTypeVert, AllowedDirectionType, Area, AutoFit, Axis, Base64, BindingLevel, BlobContent, BlockTypes, BorderType, BottomPositionInterval, BoxDir, BrkLevel, BrkScope, BrkType, CacheStrategy, CallComOption, CallOperationMode, CallOsShow, CallUDPType, CallUdpConvention, CallWsStyle, CallbackType, CharacterSet, CheckExist, CheckboxMainStyle, ChoiceControlStyle, ChoiceUtils, ColumnUpdateStyle, CompTypes, ComponentItemType, Constants, ControlStyle, CtrlButtonType, CtrlButtonTypeGui, CtrlHotspotType, CtrlImageStyle, CtrlLineDirection, CtrlLineType, CtrlOleDisplayType, CtrlOleStoreType, CtrlTextType, DBHCache, DBHRowIdentifier, DataTranslation, DataViewHeaderType, DataViewOperationType, DataViewOutputType, DatabaseDataType, DatabaseDefinitionType, DatabaseFilters, DatabaseOperations, DataviewType, DateTimeUtils, DateUtil, DbDelUpdMode, DbOpen, DbShare, DbhKeyDirection, DbhKeyIndexType, DbhKeyMode, DbhKeyRangeMode, DbhSegmentDirection, DefaultMsgDetails, DisplayTextType, DitAttribute, DitType, DriverDB, DspInterface, EndMode, EngineDirect, EnterAnimation, ErrStrategy, ErrorClassific, ExeState, ExecOn, ExitAnimation, ExportType, FieldComAlloc, FieldComType, FieldViewModelType, FldStorage, FldStyle, FlowDirection, FlwMode, ForceExit, FormDelimiter, FormExpandType, FormOperationType, FormPage, FrameLayoutTypes, GradientStyle, HTML_2_STR, HelpCommand, HelpType, HtmlAlignmentType, HttpStatusCode, ImageEffects, InitialMode, InternalInterface, ItemMasks, JSON_Utils, KeyMode, KeyboardReturnKeys, KeyboardTypes, LDir, LineDirection, LineManipulationType, ListboxSelectionMode, LnkEval_Cond, LnkMode, LoadedValues, LockingStrategy, LogType, Logger, Logger_LogLevels, Logger_MessageDirection, LogicHeaderAction, LogicHeaderType, LogicLevel, LogicOperationType, LogicUnit, MagicProperties, MediaAccess, MediaFormat, MediaOrientation, MediaType, MgControlType, MgModelType, Misc, ModelAttGuiFrame, ModelAttMerge, ModelAttRichClientFrameSet, ModelAttrBrowser, ModelAttrField, ModelAttrFramesetForm, ModelAttrGui0, ModelAttrGui1, ModelAttrHelp, ModelAttrRichClient, ModelAttrText, ModelClass, MsgInterface, NotifyCollectionChangedAction, NullArithmetic, OSEnvironment, OSType, OpenEditDialog, Opr, Order, OrientationLock, PICInterface, PaperSize, PaperSizePdfDisabled, PaperSizePdfEnabled, PositionUsage, PrgExecPlace, Priority, Queue, RaiseAt, Randomizer, RangeMode, RbAppearance, Recursion, RemarkType, RequestInfo, Resident, RowType, Rtf, Rtf_ACTN, Rtf_ErrorRtf, Rtf_IDEST, Rtf_IPFN, Rtf_IPROP, Rtf_KWD, Rtf_PROP, Rtf_PROPTYPE, Rtf_RDS, Rtf_RIS, Rtf_RtfChar, Rtf_SYMBOL, SEQ_2_HTML, SEQ_2_STR, ScrollBarThumbType, SelprgMode, SideType, SliderType, SourceContextType, SplitPrimaryDisplay, SplitWindowType, StartupMode, Storage, StorageAttribute, StorageAttributeCheck, StorageAttributeType, StrUtil, SubformType, SyncExecutionHelper, TabControlTabsWidth, TabbingCycleType, TabbingOrderType, TableBehaviour, TableType, TaskFlow, TransBegin, TransMode, TriggerType, TrueFalseValues, UndoRedoAction, UniqueTskSort, UpdateMode, UseSQLCursor, UtilDateJpn, UtilImeJpn, UtilStrByteMode, ValType, VeeDiffUpdate, VeeMode, VeePartOfDataview, VerifyButtons, VerifyDisplay, VerifyImage, VerifyMode, ViewRefreshMode, ViewSelectType, WinCptn, WinHtmlType, WinUom, WindowPosition, WindowType, XMLConstants, XmlParser, YesNoValues };
6642
+ export { APGDisplayMode, APGFormSize, APGInvokedFrom, APGMode, APGOption, APGType, Access, AlignmentTypeHori, AlignmentTypeVert, AllowedDirectionType, Area, AutoFit, Axis, Base64, BindingLevel, BlobContent, BlockTypes, BorderType, BottomPositionInterval, BoxDir, BrkLevel, BrkScope, BrkType, CacheStrategy, CallComOption, CallOperationMode, CallOsShow, CallUDPType, CallUdpConvention, CallWsStyle, CallbackType, CharacterSet, CheckExist, CheckboxMainStyle, ChoiceControlStyle, ChoiceUtils, ColumnUpdateStyle, CompTypes, ComponentItemType, Constants, ControlStyle, CtrlButtonType, CtrlButtonTypeGui, CtrlHotspotType, CtrlImageStyle, CtrlLineDirection, CtrlLineType, CtrlOleDisplayType, CtrlOleStoreType, CtrlTextType, DBHCache, DBHRowIdentifier, DataTranslation, DataViewHeaderType, DataViewOperationType, DataViewOutputType, DatabaseDataType, DatabaseDefinitionType, DatabaseFilters, DatabaseOperations, DataviewType, DateTimeUtils, DateUtil, DbDelUpdMode, DbOpen, DbShare, DbhKeyDirection, DbhKeyIndexType, DbhKeyMode, DbhKeyRangeMode, DbhSegmentDirection, DefaultMsgDetails, DisplayTextType, DitAttribute, DitType, DriverDB, DspInterface, EndMode, EngineDirect, EnterAnimation, ErrStrategy, ErrorClassific, ExeState, ExecOn, ExitAnimation, ExportType, FieldComAlloc, FieldComType, FieldViewModelType, FldStorage, FldStyle, FlowDirection, FlwMode, ForceExit, FormDelimiter, FormExpandType, FormOperationType, FormPage, FrameLayoutTypes, GradientStyle, HTML_2_STR, HelpCommand, HelpType, HtmlAlignmentType, HttpStatusCode, ImageEffects, InitialMode, InternalInterface, ItemMasks, JSON_Utils, KeyMode, KeyboardReturnKeys, KeyboardTypes, LDir, LineDirection, LineManipulationType, ListboxSelectionMode, LnkEval_Cond, LnkMode, LoadedValues, LockingStrategy, LogType, Logger, Logger_LogLevels, Logger_MessageDirection, LogicHeaderAction, LogicHeaderType, LogicLevel, LogicOperationType, LogicUnit, MagicProperties, MediaAccess, MediaFormat, MediaOrientation, MediaType, MgControlType, MgModelType, Misc, ModelAttGuiFrame, ModelAttMerge, ModelAttRichClientFrameSet, ModelAttrBrowser, ModelAttrField, ModelAttrFramesetForm, ModelAttrGui0, ModelAttrGui1, ModelAttrHelp, ModelAttrRichClient, ModelAttrText, ModelClass, MsgInterface, NotifyCollectionChangedAction, NullArithmetic, OSEnvironment, OSType, OpenEditDialog, Opr, Order, OrientationLock, PICInterface, PaperSize, PaperSizePdfDisabled, PaperSizePdfEnabled, PositionUsage, PrgExecPlace, Priority, Queue, RaiseAt, Randomizer, RangeMode, RbAppearance, Recursion, RemarkType, RequestInfo, Resident, RowType, Rtf, Rtf_ACTN, Rtf_ErrorRtf, Rtf_IDEST, Rtf_IPFN, Rtf_IPROP, Rtf_KWD, Rtf_PROP, Rtf_PROPTYPE, Rtf_RDS, Rtf_RIS, Rtf_RtfChar, Rtf_SYMBOL, SEQ_2_HTML, SEQ_2_STR, ScrollBarThumbType, SelprgMode, SideType, SliderType, SourceContextType, SplitPrimaryDisplay, SplitWindowType, StartupMode, Storage, StorageAttribute, StorageAttributeCheck, StorageAttributeType, StrUtil, SubformType, SubscriberClient, SyncExecutionHelper, TabControlTabsWidth, TabbingCycleType, TabbingOrderType, TableBehaviour, TableType, TaskFlow, TransBegin, TransMode, TriggerType, TrueFalseValues, UndoRedoAction, UniqueTskSort, UpdateMode, UseSQLCursor, UtilDateJpn, UtilImeJpn, UtilStrByteMode, ValType, VeeDiffUpdate, VeeMode, VeePartOfDataview, VerifyButtons, VerifyDisplay, VerifyImage, VerifyMode, ViewRefreshMode, ViewSelectType, WinCptn, WinHtmlType, WinUom, WindowPosition, WindowType, XMLConstants, XmlParser, YesNoValues };
6496
6643
  //# sourceMappingURL=magic-xpa-utils.mjs.map