B4J Question Send and recieve File and text messages between client and server

Discussion in 'B4J Questions' started by ArminKH, Jun 4, 2015.

  1. ArminKH

    ArminKH Well-Known Member

    hi
    i am so confused if is possible please help me
    i want following futures:
    1-send and recieve file and text message on real time (socket) between b4a and a b4j server
    2-delivery report

    now i have 2 way
    1-use jNetwork + AsyncStreamObject
    2- use jWebSocketClient + jServer

    i have not any problem with way 1 and all things are okay
    but how is possible this steps on way 2?
    1-send and recieve files
    as i know and i see on tutorials we can just send text messages to server!!!
    by using async stream object that is so simple but i dont know any way to do this with way 2
    2-delivery report
    on way 1 we have async stream and that has events 4 managing this problem but i cant find any relevant tutorial for delivery report when i use jserver and jwebsocketclient

    as @Erel said we should use jnetwork 4 low level socket,so now i want to do this with jserver + websocket

    and if you want to help more please please please tell me the basic difference between This 2 technology.
    and at last

    i know i confused 2 technology and excuse me 4 my english.maybe this is not just my question and some others are confused similar to me

    thank u
     
  2. ArminKH

    ArminKH Well-Known Member

    @klaus
    Any idea ? :( this is neccessary 4 me
     
  3. Reids

    Reids Member Licensed User

    What do you want to achieve? do you want create a chat apps or something?
    1.it depend what do you want to achieve, if you want to create a chat apps, and send an image on realtime, you could send it with http request and notice the other user with socket message
    2.delivery report can be achieved with server side code, you can tell message is delivered or not by :
    a.checking is other user socket session is active or not
    b.is activate send the message, is error or not
    c.is error message is not delivered
     
    ArminKH likes this.
  4. ArminKH

    ArminKH Well-Known Member

    Thank u yes i want to create a small chat app
    By using jnetwork + async stream object we send an image to server and our image saved on a object variable and then send that object to other client
    But on your way we sholud send the image by httputils to a temporary folder on server and then after delivered then we can remove that
    But if we want.to files not saved on temp folder what is the solution?
    And i am not sure i understand your delivered solution(a , b , c)
    I think by using this way all messages must be saved on a database???
    Is there any simpler way similar to async stream?
    And if is possible please explain the base diffrence between jserver + websocket and jnetwork+async stream
    Thank u very much
     
  5. Reids

    Reids Member Licensed User

    Is it desktop chat apps or android chat apps?
    I'm not familiar to java but I familiar with basic,c# or any visual studio so I used basic4 product :D to cover my weakness on java, on my chat apps, I'm using custom server code using visual basic and basic4android :
    how to delivery system :
    1.All you need is knowing the basic of socket system, it is understanding socket id
    2.Every on_connect() system will generate new socket id
    3.sending my chat system using function send(targetsocketid,message)
    4.reading if message delivered is by checking if send() function is running success or fail, if fail of course message is not delivered
    5.undelivered message is saved on mysql database on server side, but delivered message is just send as is as to client, and on client side will saved it on sqlite database for some reason user want to re read the message
    6.if target id reconnected to socket server, message will be resend to target id

    So All message is saved on client sqlite database, undelivered message only is saved in server mysql database only if message not delivered
    if disconnected target client got connected, on_connect() event will fetch those message on server and resend it to the client

    Hope it help
     
    ArminKH likes this.
Loading...