B4J Question Converting PushServer Non UI to UI

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
I'm trying to convert PushServerNoMySQL to UI application.

In debug mode it runs perfectly.

The problem only appears in release mode when I refresh the browser:

B4X:
'WebSocket class
Sub Class_Globals
    Private ws As WebSocket 'ignore
    Private btnSend, txt As JQueryElement
    Private users As JQueryElement
    Private tblMessages As JQueryElement
End Sub

Public Sub Initialize
Log("->PushBrowser/Initialize")   
End Sub

Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Log("->PushBrowser/WebSocket_Connected")
    ws = WebSocket1
    CallSubDelayed2(PushShared, "NewBrowserConnection", Me)
    tblMessages.RunMethod("dataTable", Array As Object( _
        CreateMap("bFilter": False, "bPaginate": False, "bSort": False, _
            "bAutoWidth": False, "aoColumns": Array As Object(CreateMap("sWidth": "20%"), CreateMap("sWidth": "80%")))))
    UpdateMessagesTable
End Sub

Private Sub btnSend_Click (Params As Map)
Log("->PushBrowser/btnSend_Click")
    Dim f As Future = txt.GetVal
    Dim msg As String = f.Value
    msg = msg.Trim
    If msg.Length > 0 Then
        CallSubDelayed3(PushShared, "NewMessage", msg, Null)
    End If
    txt.RunMethod("select", Null)
End Sub

Public Sub UpdateMessagesTable
Log("->PushBrowser/UpdateMessagesTable")
    DBUtils.FillTable(ws, tblMessages, _
    PushShared.PushDB.ExecQuery("SELECT msg_id, text, time FROM messages ORDER BY msg_id DESC LIMIT 20"))
    ws.Flush
End Sub

Public Sub UpdateConnectedIds(s As String)
Log("->PushBrowser/UpdateConnectedIds")
    users.SetHtml(s)
    ws.Flush
End Sub

Private Sub WebSocket_Disconnected
Log("->PushBrowser/WebSocket_Disconnected")
    CallSubDelayed2(PushShared, "BrowserDisconnected", Me)
End Sub

The log:
B4X:
Program started.
2014-08-04 14:26:29.543:INFO::JavaFX Application Thread: Logging initialized @361ms
->Init
->CreatePushTables
Version DB: 1.100000023841858
2014-08-04 14:26:29.605:INFO:oejs.Server:JavaFX Application Thread: jetty-9.1.z-SNAPSHOT
2014-08-04 14:26:29.620:WARN:oejh.MimeTypes:JavaFX Application Thread: java.util.MissingResourceException: Can't find bundle for base name org/eclipse/jetty/http/encoding, locale es_ES
2014-08-04 14:26:29.635:INFO:oejsh.ContextHandler:JavaFX Application Thread: Started o.e.j.s.ServletContextHandler@44a44891{/,file:/C:/Dropbox/Epai/Android/BJA/Programas/BostonChef/PushServerNoMySQL/Objects/www/,AVAILABLE}
2014-08-04 14:26:29.637:INFO:oejs.AbstractNCSARequestLog:JavaFX Application Thread: Opened C:\Dropbox\Epai\Android\BJA\Programas\BostonChef\PushServerNoMySQL\Objects\logs\b4j-2014_08_04.request.log
2014-08-04 14:26:29.651:INFO:oejs.ServerConnector:JavaFX Application Thread: Started ServerConnector@3e1d1648{HTTP/1.1}{0.0.0.0:51042}
2014-08-04 14:26:29.652:INFO:oejs.Server:JavaFX Application Thread: Started @487ms
Server started
->PushBrowser/Initialize
java.lang.RuntimeException: not supported
    at anywheresoftware.b4j.objects.FxBA.cleanMessageLoop(FxBA.java:37)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:186)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
->PushBrowser/WebSocket_Disconnected
->BrowserDisconnected
->Initialize
java.lang.RuntimeException: not supported
    at anywheresoftware.b4j.objects.FxBA.cleanMessageLoop(FxBA.java:37)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:186)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
->WebSocket_Disconnected

When I connect from Android app, the same error appears.
 

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
I have configured to run the non-UI app server in the Startup of Windows. I don't know why, but sometimes, the server doesn't start.

I wanted to convert it to a UI app to can put a system tray icon and can see easily if the server is running or not.

Can I run the app server from an UI app if the server is not running? How?

Thanks.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Did somebody knows, which is the best to communicate from an ui-app to a server-app? I want to show the logs in the ui-app. I'm looking for the best solution...

Thanks for help...
 
Upvote 0
Top