Android Tutorial Custom WebSocket Based Push Framework

vfafou

Well-Known Member
Licensed User
Longtime User
Hi!
Does anyone have figured how to send messages from client to server? I've tried without luck! I think I'm missing something!
 

vfafou

Well-Known Member
Licensed User
Longtime User
It's all OK! I can now send messages from my Android phone.
Does web socket support simple socket connections?
I need to connect an old VB6 application to the B4J server in order to send/receive messages to/from Android tablets via internet?
Or I have to implement a simple socket server into B4J server?
Which is the best practice?

Thank you in advance!
 

vfafou

Well-Known Member
Licensed User
Longtime User
No.

You will need to open another port on the server and listen to incoming connections with ServerSocket. A simpler solution will be to send regular http requests from your VB6 app and handle them with a regular server handler.

Thank you Erel!
I'll try to implement both solutions and see which is more suitable for my needs!
 

Levisvv

Member
Licensed User
Longtime User
does this library use only the cellular connection or will it also try the wifi connection?
I ask because I tried redirecting it to connect to a local TCP/IP server, but the android app report a timeout..
B4X:
Sub Process_Globals
    Public serverLink As String = "ws://192.168.1.121:7234"
End Sub

can anybody think of any reason why this never connected?
 

tigrot

Well-Known Member
Licensed User
Longtime User
Hi there,
I was wondering if the system would be limited by total number of connections per server or only by processing power. I'd like to use in a big network where a static connection whould be impossibile. I'm now using a poll, but I have long delays.
Regards
Mauro
 

Silv

Member
Licensed User
Longtime User
I have problem to connect to this serverLink ws://basic4ppc.com:51042/push/b4a_ws2 . Is anybody have the same problem?
 

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I'm trying to send message from my android client to server, running the following code
B4X:
Public Sub SendEventToServer(Event As String, Data As Map)
    Dim m As Map
    m.Initialize
    m.Put("type", "event")
    m.Put("event", Event)
    m.Put("params", Data)
    Dim jg As JSONGenerator
    jg.Initialize(m)
    ws.SendText(jg.ToString)
End Sub

Public Sub SendMessageToServer(mText As String, mId As String)
   
    Dim data As Map
   
    data.Initialize
    data.Put("id", mId)
    data.Put("message", mText)
   
    SendEventToServer("Device_Message", data)
   
End Sub
The server has the event Device_Message:
B4X:
Public Sub Device_Message(Data As Map)
   
    id      = Data.Get("id")
    mText = Data.Get("message")
   
    CallSubDelayed3(PushShared, "NewMessage", mText, Null)
   
    Log("Message From ID: " & id & ": " & mText)

End Sub

Server can send messages to device, via PushBrowser class.
What am I doing wrong?

Thank you in advance.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I took down this online example as it seems that someone has started "spamming" the system sending several hundreds of gibberish messages each day

Polling will require more resources. What is the estimated number of connections?
 

defillo

Member
Licensed User
Longtime User
Hello Erel

maybe I'm lazy in searching or simply something is not clear enough to me.. I have several domains hosted by an internet provider, all under linux servers.
Suppose I would like to use this servers for webapp push notifications.
what are the files I do have to upload and what is the link to connect to? tried several ways but with no result (I don't even know if webapp is allowed or not, but should be..)
 

tigrot

Well-Known Member
Licensed User
Longtime User
Note: there are toooo many idiots, everywhere.
Luca vai sicuro, che con un poll ogni 30sec. (keep-alive) il tuo server dopo i primi 10K clienti scoppia... Io l'ho installato su un server cloud di Aruba e va molto bene, ma ogni cliente chiede un socket e i socket sono limitati, a menu che ti riscrivi Linux come hanno fatto i vari network.
Puoi fare un test generando da un client 10K connessioni e guarda che succede. Mezz'ora di coding...

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