Other Subscribe to B4J library updates

stevel05

Expert
Licensed User
Longtime User
Project Overview

Update to v0.6

v0.6 Bug fix for crash when filtering on Modules or Module Descriptions
 

stevel05

Expert
Licensed User
Longtime User
[B4x] LED Matrix

This is a Custom view b4xlib that I created to add to my LogServer, I though it may come in handy for other purposes so I'd share it here.
You can have any number of channels (Rows) and a practical limit of 16 LED's (Columns) per channel as the state for each channel is stored in an Int, which is a 16 Bit variable.
 

stevel05

Expert
Licensed User
Longtime User
LogServer

V1.10 Client Library updated to work with Non_UI apps in java 9+
 

stevel05

Expert
Licensed User
Longtime User
Create b4xlib files from projects

Update v 1.4
  • Added create XML from deployed library using Erels code from V1.21 : b4xlib2XML
  • Improved manifest management
  • Added manifest Author and Version fields to the Gui
  • Added check for removed folders
  • Small bug fixes
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
b4xlib - XML generator V1.22 - Fixes an issue where the return type of subs without parameters was not added. Thank you @stevel05!

 

stevel05

Expert
Licensed User
Longtime User
B4x Library Documentation viewer

  • Load a documentation XML file.
  • Drag and drop XML documentation files from the File Manager.
  • Drag and drop XML documentation files from the B4x Forum and save them locally.
  • Export the documentation as HTML pages, if there is more than one class in a library an index page is created with working links
  • Export the documentation as B4xForum friendly bbcode pages or add to the clipboard (one page at a time)
 

alwaysbusy

Expert
Licensed User
Longtime User
BANano v4.50

This version introduces the BANanoServer b4xlib library, which makes the B4J connection full circle:

The BANanoServer.b4xlib library, source code and demo can be found in the zip in BANano4.50\B4JServerDemo\New System 4.50+\

It add some specific methods to BANano that can only be used when you use this BANanoServer.b4xlib library!

In the B4J IDE there are three new templates classes added :

a. BANanoServer SERVER Class: a template of the server side of a page
b. BANanoServer BROWSER Class: a template of the browser side of a page
c. BANanoServer SHARED Class: a template of a class that can be used both in BANano and B4J.

Use to specify which code is specific for the BANanoServer (B4J) and the BANano Browser part in c.
B4X:
#If #B4J

#Else

#End If

Making changes a this class in B4J debug mode will NOT have any effect on the BANano side until recompiled!

If you want a specific class/module to be transpiled, use the following on top of your class/module:

B4X:
#Region BANano
    ' <-------------- IMPORTANT! This is because we want the non specific B4J code in this module to be transpiled by BANano
#End Region

--------------------------------------------
1. [NEW] a BANano event _ParseEvent(params As Map)

Typically used in a SERVERClass to process an event coming from the browser

B4X:
' event raised to distribute incoming events coming from the BROWSER
public Sub BANano_ParseEvent(params As Map)
    Main.Server.ParseEvent(Me, ws, CacheReport.BANPageID, CacheReport.BANSessionID, params)
End Sub

2. [NEW] a BANano event _Uploaded(status As Int, fileName As String)

Typically used in a SERVERClass to handle an UploadFile

B4X:
' event raised when a file has been uploaded
public Sub BANano_Uploaded(status As Int, fileName As String)
    Log(fileName & " = " & status)
    Select Case status
        Case 200 ' OK
        Case 500 ' was not a POST call
        Case 501 ' file to big
        Case 502 ' file type not allowed
    End Select
End Sub

3. [NEW] BANano.TranspilerOptions.SetStaticFolder() and BANano.StaticFolder (get)

SetStaticFolder has to be used in the AppStart method.
StaticFolder (get) can be used both in B4J as in a BANano class/module.

4. [NEW] BANano.GetPageID

On the Browser side, here you can read the unique page ID (autogenerated)

5. [NEW] UploadFile: Uploads a file from the browser side to the BANanoServer

B4X:
' uploading a file to our server
Sub SKButton1_Click (event As BANanoEvent)
    Dim Response As BANanoObject
    ' get the file object
    Dim theFile As BANanoObject = SKTextBox1.File
    If theFile = Null Then
        BANano.Alert("Please select a file first!")
        Return
    End If
    ' prevent big uploads
    If theFile.GetField("size") > 1024 * 1024 * 5 Then
        BANano.Alert("File is to big!")
        Return
    End If
    ' returns a promise
    Dim prom As BANanoPromise = BANano.UploadFile(theFile)
    prom.Then(Response)
        SKLabel1.Text = "Upload status: " & Response.GetField("status").Result
    prom.Else(Response)
        Log(Response)
    prom.end
End Sub

6. [NEW] New class BananoCacheReport, which returns more info of the cached page.

typical use is on the SERVER side:

B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    Log("Connected")
   
    ws = WebSocket1
   
    ' Lets update the cache with this class
    CacheReport = Main.Server.UpdateFromCache(Me, ws)
    Log("PageID: " & CacheReport.BANPageID)
    Log("Comes From Cache:" & CacheReport.ComesFromCache)
    Log("Is a reconnecting socket: " & CacheReport.IsReconnected)
   
    ' We can already send stuff to the browser, using normal B4J jServer code with Future
    Dim fut As Future = ws.RunFunctionWithResult("AddInTheBrowser", Array(20, 30))
    ws.Flush
    Log("BROWSER says sum of 20+30=" & fut.Value)
   
    ' or if no result is expected back
    ws.RunFunction("BROWSERTest", Array("Hello from the SERVER!"))
    ws.Flush
       
    ' IMPORTANT lets tell the browser we are ready to receive call from the browser
    ' Uses the classic WebSocket_Connected and WebSocket_DisConnected events on the browser size
    ' Use Main.Server.SendReady(ws, "ws") if you use the advanced events OnOpen, OnMessage, OnServerReady, ...
    Main.server.SendConnected(ws)   
End Sub

7. [NEW] BANano.B4JCallSubX(Component as Object, Sub as String, Arguments as List)

Similar to CallSub, but with unlimited arguments. Arguments must be passed as an Array.
Can only be used in pure B4J, not in a BANano module!

8. [NEW] BANano.TranspilerOptions.SetSessionMaxInactiveInterval

Sends a heartbeat. Only applicable if a BANanoServer is used.
Should be the same a the BANanoServer.SessionMaxInactiveInterval

9. [NEW] BANanoWebSocket.RunFunctionWithResult

Similar to RunFunction. Returns a BANanoPromise with the result.

10. [NEW] BANanoWebSocket.RunFunction

Runs a B4J function. Pass null to Args if is not needed.

11. [NEW] BANanoWebSocket.IsReconnected

In case of a Reconnecting Websocket, you can check if this was a reconnected session


--------------------------------------------
Used in the BANanoServer library.
In most cases you do not have to use these methods directly but use the BANanoServer methods instead

12. [NEW] BANano.UploadHandlerPath, use BANanoServer.UploadFolder instead

Sets/Gets the folder where Uploads are put

13. [NEW] GetPageHTML. Used internally.


Other changes:
---------------------------------------------

14. [NEW] BANAno.CallBackExtra

Useful where a library you are wrapping needs a function() {} as parameter.

The params are the 'event' params like in the normal CallBack.
The extraParams are extra parameters that the callback method takes, not default to the callback

Example:
B4X:
Sub GetFileFromServer(FileName As String)
      Dim Response As BANanoFetchResponse
    Dim Blob As BANanoObject
   
    ' list (GET is default, and we do not need extra options so we pass Null for the options)
    Dim fetch1 As BANanoFetch
    fetch1.Initialize(FileName, Null)
    fetch1.Then(Response)
        ' we got the response promise, so resolve it to a blob
        fetch1.Return(Response.Blob)
    fetch1.Then(Blob)
        ' we got the blob, read it in a FileReader
        Dim FileReader As BANanoObject
        FileReader.Initialize2("FileReader", Null)
        Dim event As BANanoEvent
        ' the CallBackExtra, which next to the normal event, also we like to pass the filename
        FileReader.SetField("onload", BANano.CallBackExtra(Me, "ReadData", Array(event), Array(FileName)))
        ' get the DataURL
        FileReader.RunMethod("readAsDataURL", Blob)           
    fetch1.End ' always end a fetch with this!   
End Sub

Sub ReadData(event As BANanoEvent, FileName As String) 'ignore
    ' get the data
    Dim Target As BANanoObject = event.OtherField("target")
    Dim DataUrl As String = Target.GetField("result").Result
    Log(FileName)
    log(DataURL)   
End Sub

15. [NEW] BANano.GetFileAsDataURL

Does a Fetch with a resource (e.g. url) and an optional Request options object
Pass null if no request options need to be set

Returns a promise holding the DataURL

B4X:
Dim dataUrl As String
Dim dataUrlProm As BANanoPromise = BANano.GetFileAsDataURL("./assets/B4X.jpg", Null)
dataUrlProm.Then(dataUrl)
         Log(dataUrl)
dataUrlProm.end

16. [NEW] BANano.GetFileAsText

Does a Fetch with a resource (e.g. url) and an optional Request options object
Pass null if no request options need to be set

Returns a promise holding the text

17. [NEW] BANano.GetFileasJSON

Does a Fetch with a resource (e.g. url) and an optional Request options object
Pass null if no request options need to be set

Returns a promise holding the JSON

18. [NEW] BANano.GetFileAsArrayBuffer

Does a Fetch with a resource (e.g. url) and an optional Request options object
Pass null if no request options need to be set

Returns a promise holding the ArrayBuffer

-------------------------------------------------------
New in BANanoPromise

19. [NEW] Promise.NewStart & promise.NewEnd

Make a new Promise with this signature:

B4X:
Dim prom as BANanoPromise
prom.NewStart
   ...
   BANano.ReturnThen(ret)
   ...
   BANano.ReturnElse(ret)
prom.NewEnd
prom.Then(response)

prom.Else(response)

prom.End

Transpiles to:

B4X:
prom = new Promise(function(resolve, reject) {
  ...
  resolve(ret);
  ...
  reject(ret)
});
prom.then(function(response) {

}).else(function(response) {

});

Example:
B4X:
Dim response As String   
Dim prom As BANanoPromise 'ignore
prom.NewStart
        BANano.ReturnThen("Alain")
prom.NewEnd
prom.Then(response)
        Return "Hello " & response & "!" 'ignore
prom.Then(response) 'ignore
        Log(response) ' prints: Hello Alain!
prom.end

20. [NEW] Promise.then now returns a BANanoPromise

---------------------------------------------
BANano.TranspilerOptions:

21. [NEW] BANano.TranspilerOptions.IgnoreB4JLibrary

A B4J library the BANano Transpiler should ignore.

By default, the following are ignored:

BANano
BANanoServer
jCore
jFx
jServer
JavaObject
ABJJWT

22. [NEW] BANano.TranspilerOptions.SetSessionMaxInactiveInterval

Sends a heartbeat. Only applicable if a BANanoServer is used.
Should be the same a the BANanoServer.SessionMaxInactiveInterval

---------------------------------------------
BANanoWebsocket:

23. [NEW] New websocket events.

NOTE:
.Initialize will raise the 'normal' B4J WebSocket events
.InitializeExtended will raise the more advanced websocket events

For the usage of the events, see the demo

OnConnecting(event As BANanoEvent)
OnServerReady()
WebSocket_Connected()
WebSocket_Disconnected(event As BANanoEvent)

24. Other minor Transpiler fixes and optimisations

Download: https://www.b4x.com/android/forum/t...-abstract-designer-support.99740/#post-627764

Alwaysbusy
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…