question

vishal388 avatar image
vishal388 asked David Marginian answered

Handling connector with multiple tabs

I am doing semi integration using remote cloud Sdk using JavaScript. I am opening/creating a connector when user first attempts to use our web based POS and and keep using the same connector for subsequent connection until browser window is closed.

However I noticed that by mistake when duplicated the tab and attempted payment, I got error saying same friendlyid is used.


How can I either safely dispose and open connection to Clover device or get the open connection and reuse that in duplicated tab?

semi-integrationsClover Flex
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian answered

I looked into this. The reason this is happening is because you are using the same friendly ID for two different connections. You need to be using a different friendly ID on the second and all subsequent tabs. If you do, onDeviceError will be called. This isn't an issue in the sdk.

1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks David for your help on this.

0 Likes 0 ·
David Marginian avatar image
David Marginian answered David Marginian converted comment to answer

You can't have more than one connection to the device. Generally the way to handle this is to check for that error on the second tab, and then prompt the user asking them if they would like to force the connection. If they say yes there's a force connect flag on the configuration. Setting that to true will disconnect the first tab and allow the second tab to connect.

13 comments
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Which event callback I shall use to check if there is already a connector open? When I look at the onDeviceError event callback, I get nothing. In the console, I do see warn from clover library but my question is how do I intercept it to show the popup to user if they want to force us the clover in the current tab?


1613236524932.png

0 Likes 0 ·
1613236524932.png (29.4 KiB)

I thought it was onDeviceError it may be onDeviceDisconnected. Just look in the sdk source if you need an answer now. Otherwise I can look later.

0 Likes 0 ·
vishal388 avatar image vishal388 David Marginian ♦♦ ·

Looking at SDK, it is not returned in neither onDeviceError nor onDeviceDisconnect (this one does not have any object on return call).


https://github.com/clover/remote-pay-cloud/blob/c9c2c16d42e7e55984016475e3ed47bef5a1817b/src/com/clover/remote/client/transport/websocket/WebSocketCloudCloverTransport.ts#L197

All it is doing is to log. I think this should be returned as error code. Again, not sure if I am looking at right place or not that is the only place I can see the error message around friendly Id in use.


Looking at past history: https://github.com/clover/remote-pay-cloud/issues/147


https://github.com/clover/remote-pay-cloud/blob/bc1bc6fec041484b9fcfee8d2665a4fd0a654c3e/src/com/clover/remote/client/transport/websocket/WebSocketCloudCloverTransport.ts#L173

Just wondering if line should have been moved in the if block instead of removing?

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community