@@ -1317,6 +1317,7 @@ class BaseCommunicationClient extends IPreswaldCommunicator {
13171317 type : 'error' ,
13181318 content : {
13191319 message : error . message ,
1320+ fullError : error . toString ( ) ,
13201321 context,
13211322 timestamp : performance . now ( ) ,
13221323 transport : this . constructor . name
@@ -1349,7 +1350,7 @@ class BaseCommunicationClient extends IPreswaldCommunicator {
13491350}
13501351
13511352class WebSocketClient extends BaseCommunicationClient {
1352- constructor ( ) {
1353+ constructor ( config = { } ) {
13531354 super ( ) ;
13541355 this . socket = null ;
13551356 this . clientId = Math . random ( ) . toString ( 36 ) . substring ( 7 ) ;
@@ -1358,13 +1359,12 @@ class WebSocketClient extends BaseCommunicationClient {
13581359 this . maxReconnectAttempts = 5 ;
13591360 this . reconnectDelay = 1000 ;
13601361
1361- // Enhanced transport optimization features
13621362 this . messageQueue = [ ] ;
1363- this . maxQueueSize = 1000 ;
1364- this . batchingEnabled = true ;
1363+ this . maxQueueSize = config . maxQueueSize || 1000 ;
1364+ this . batchingEnabled = config . batchingEnabled !== false ;
13651365 this . batchTimeout = null ;
1366- this . batchSize = 10 ;
1367- this . batchDelay = 16 ; // ~60fps for UI responsiveness
1366+ this . batchSize = config . batchSize || 10 ;
1367+ this . batchDelay = config . batchDelay || 16 ;
13681368
13691369 // Compression statistics for monitoring
13701370 this . compressionStats = {
@@ -1806,16 +1806,16 @@ class WebSocketClient extends BaseCommunicationClient {
18061806}
18071807
18081808class PostMessageClient extends BaseCommunicationClient {
1809- constructor ( ) {
1809+ constructor ( config = { } ) {
18101810 super ( ) ;
18111811
1812- // Enhanced transport optimization features for PostMessage
18131812 this . messageQueue = [ ] ;
1814- this . maxQueueSize = 500 ; // Smaller queue for PostMessage due to potential parent window limitations
1815- this . batchingEnabled = true ;
1813+ this . maxQueueSize = config . maxQueueSize || 500 ;
1814+ this . batchingEnabled = config . batchingEnabled !== false ;
18161815 this . batchTimeout = null ;
1817- this . batchSize = 8 ; // Smaller batch size for PostMessage
1818- this . batchDelay = 20 ; // Slightly higher delay for PostMessage
1816+ this . batchSize = config . batchSize || 8 ;
1817+ this . batchDelay = config . batchDelay || 20 ;
1818+ this . messageSequence = 0 ;
18191819
18201820 // Serialization optimization statistics
18211821 this . serializationStats = {
@@ -2193,10 +2193,18 @@ class PostMessageClient extends BaseCommunicationClient {
21932193}
21942194
21952195class ComlinkClient extends BaseCommunicationClient {
2196- constructor ( ) {
2196+ constructor ( config = { } ) {
21972197 super ( ) ;
21982198 console . log ( '[Client] Initializing ComlinkClient' ) ;
21992199 this . worker = null ;
2200+
2201+ this . messageQueue = [ ] ;
2202+ this . maxQueueSize = config . maxQueueSize || 100 ;
2203+ this . batchingEnabled = config . batchingEnabled !== false ;
2204+ this . batchTimeout = null ;
2205+ this . batchSize = config . batchSize || 5 ;
2206+ this . batchDelay = config . batchDelay || 50 ;
2207+
22002208 // Note: callbacks, componentStates, isConnected, pendingUpdates
22012209 // are now inherited from BaseCommunicationClient
22022210 }
@@ -3163,11 +3171,11 @@ export const createCommunicationLayer = (config = {}) => {
31633171function createTransportClient ( transportType , config ) {
31643172 switch ( transportType ) {
31653173 case TransportType . WEBSOCKET :
3166- return new WebSocketClient ( ) ;
3174+ return new WebSocketClient ( config ) ;
31673175 case TransportType . POST_MESSAGE :
3168- return new PostMessageClient ( ) ;
3176+ return new PostMessageClient ( config ) ;
31693177 case TransportType . COMLINK :
3170- return new ComlinkClient ( ) ;
3178+ return new ComlinkClient ( config ) ;
31713179 default :
31723180 throw new Error ( `Unsupported transport type: ${ transportType } ` ) ;
31733181 }
0 commit comments