B4J Tutorial AsyncStreamsObject - Send and receive objects over the network

For new projects it is recommended to use B4XSerializator instead of this solution.



SS-2013-11-14_13.26.52.png


AsyncStreamsObject allows you to send and receive objects instead of bytes.
You can read more about it here: http://www.b4x.com/android/forum/th...d-and-receive-objects-instead-of-bytes.30543/

This example connects to the same Android example and allows you to communicate with the device.
The device app acts as the server as the desktop firewalls usually blocks incoming connections.

You can download the Android example here: http://www.b4x.com/android/forum/th...e-objects-instead-of-bytes.30543/#post-202288
Make sure to update B4A RandomAccessFile library to v1.6: http://www.b4x.com/android/forum/th...handle-streams-of-any-size.30494/#post-177051

Once you have a valid connection it is very simple to send and receive custom types, drawings, collections and files.
 

Attachments

  • AsyncStreamsObject.zip
    4.1 KB · Views: 3,442
Last edited:

myriaddev

Active Member
Licensed User
Longtime User
WoW! I got both sides to work (Android and PC)!! How do I pass the
"correct/original fileNames" to the otherside ? I currently get internal names of
the files that increment for the temporary file names on each side.
THANKS!!!
 
Last edited:

YIM bunchhat

Active Member
Licensed User
Longtime User
It is so cool....:). Excuse me, Is there any way to send without wifi but via internet?, Ex: the same as Skype.
 

YIM bunchhat

Active Member
Licensed User
Longtime User
Hello Erel,
After I read briefly, I think it is not what I want to do. I am interesting in communication from one device to other device wireless. I ever ask you about CCTV from phone to phone, now I can make it work properly. but I want to upgrade it use without wifi but via internet. I think is the same to Skype that can chat, can live video, send file..etc.....:D
 

myriaddev

Active Member
Licensed User
Longtime User
I am now getting IP: 192.168.2.1 after BAJ 1.0 and using ipconfig it tells me
local ip is 192.168.0.97.
On client's xp AsyncStreamsObject IP: 192.168.2.1 and its local ip 192.168.0.28.
Before BAJ 1.0, I could connect.
Please help.
 

myriaddev

Active Member
Licensed User
Longtime User
Hi Erel. I took your idea, and removed VMware and Virtualbox from my Windows 7 system
and now AsyncStreamObject BAJ now correctly reports it's local IP! THANKS!!

Currently I can connect from PC to Android(s), and from Android to Android but NOT from
Android to PC (two physical locations)l?! Works great once connected. Any ideas ?
 

slowtime

Active Member
Licensed User
Longtime User
Hi,
If I change in AsyncStreamsObject TempFolder="C:\" (or other Path ) I can't receive file.

B4X:
Public Sub Initialize (TargetModule As Object, EventName As String)
    target = TargetModule
    Event = EventName
    'TempFolder = File.DirTemp
    TempFolder="c:\"
    Log(File.DirTemp)
End Sub

Can you help me ?

Thank you
Ciao
 

slowtime

Active Member
Licensed User
Longtime User
Thank you, but c:\temp is not the solution. It is strange; file.dirTemp resuts inside a path locked in Windo seven but it is running. I also tryied in a usbPen Drive and a external HD but it is not run.
Ciao and good year.
 

pauleffect

Member
Licensed User
Longtime User
could it be ported to visual studio? i know it's a long shot but....

I'm trying to append some macro for automation purposes and i'd be great if i could cut the middleman, so to speak.
 
Top