Conversation
Been trying to get this client to work properly in the browser, and noticed there are a couple of things that will need fixing to complete it. - Added a warning when trying to subscribe and its not connected - Added the ability to subcribe to public channels - Added a key check when using empty string - Disable auto connect by default - Added setting on connection callback feature - Added setting on disconnection callback feature - Added the ability to set if the channel is public or not using `is_public` Regards
Updated the query authentication mechanism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Been trying to get this client to work properly in the browser, and noticed there are a couple of things that will need fixing to complete it.
Added a warning when trying to subscribe and its not connected
While working, I had instances whereby I was trying to setup the connection, and then subscribe immediately. As I was trying different api keys, I had no idea of telling if the connection had been established or not. After some internal debugging, I figured out the reason it subscribed sometimes and didn't was because I was trying to subscribe before the connection was established; and there was no warning to tell me this. So why I added this.
Added the ability to subscribe to public channels
From all indications, it seems when using this client api, it is not allowed to subscribe to publish channels. Since I have to
auth_endpointyet in my application, I cannot work with private for now (unless I am wrong), and why I added the ability to instruct it using theis_publickey, so it will allow to make use of public channels as wellAdded a key check when using empty string
When I used an empty string as api key, it seemed to be it had connected and I couldn't tell if it had or not due to no enough information being sent to console to tell. So this helps with that
Added setting on connection callback feature
Initially when I was working with this api, as I was connecting and trying to subscribe immediately, it wasn't working as I really had no way to know if it had connected or not. Within the
bbt.jsfile, it does have anonConnectioncallback, but this was no available for one to use for other things (unless I am wrong, so forgive my noob level ;)). So added the ability to specify a callback, which will be ran when a connection is made. This will then allow the user to do other things which needs connection like subscribe to channels and all.Added setting on disconnection callback feature
Similar to the above but for disconnection this time. Even internally this was disregarded, so had to add it so users can use the callback to do other stuffs when writting code
Disable auto connect by default
Auto connecting by default, didn't allow for time to do other things before the connection is made, like specifying an
on_connectoron_disconnectcallbackAdded the ability to set if the channel is public or not using
is_publicThis became necessary as it seems the client api is only designed to connect to private channels, when the
writeis enabled. I can understand the reason for extra security, but not everyone has all the backend infrastructure to setup the connection endpoint. Besides my app is to run in standalone mode as a PWA, so there is no way I will be using an authentication urlFix for a few bugs
Documentation will need more explanation in general, if my PR is accepted and will be willing to help with that.
Regards