2016년 12월 27일 화요일

Client Socket Extension made, testers wanted


Last year, I needed a component in AI2 that did the work of a client socket. As there wasn't any, I used Web component instead, but it didn't do everything I need. A few days ago, I saw that there were the possibility to use extensions, but didn't find a client socket one. I decided to make one so.

Here it is : ClientSocket extension V0.4.1 !

Properties :
- serverAddress (R/W)
- serverPort (R/W)
- hexaStringMode (R/W)
- connectionState (RO)

Methods :
- Connect
- Disconnect
- SendData

Events :
- DataReceived
- RemoteConnectionClosed

Known bugs :
- I think that only messages less than 1024 bytes work
- before launching connect method, you should rewrite properties serverAddress and serverPort

If you want to send non ascii data, modify hexaStringMode to true and send data as "303132" to send characters 012. Received string will be also hexa characters.

If you can, you can use it, test it and report me suggestions and bugs.


------
It is really nice that you made this, although personally I am not quite sure what to do with it. Mabe you could add a description, or an example?

For us to use it though, you should provide it as an .aix file, that allows user to load it into their project.
I am sure it is described in the documentation how to create the .aix file: http://ai2.appinventor.mit.edu/reference/other/extensions.html


--
aix file is given (the first file), but I have problems when I try to connect MIT AI2 companion, it says "no such class". I saw someswhere in the docs that there may be problems if I don't name the extension properly, maybe it is the reason why it's not working ?

The exemple of use ? The one I will do is a connection between an arduino and AI2, I will be able to contact the arduino from AI2, but now also, the arduino will be able to contact AI2 app (with Web component, AI2 app could only be the one which initiate communication, it asks and arduino reponds, with a socket, arduino can send information without being asked to by AI2 app). But it is only a very small part of what you can do with a client socket ...

--
Another question : where do I have to put the icon I want to give to the extension ? I tried many path, but I always see brocken linked image for the icon.

--
I expect Taifun knows the answer to your questions.

--
New Version 0.2 :

- Better error message display
- aix file size reduced
- example app

--
 I saw that there were the possibility to use extensions, but didn't find a client socket one. I decided to make one so.
great idea! thank you for your contribution!
as I can see, you found how to rename the package name meanwhile
concerning the icon, you have to use the default extension icon or provide the icon in the internet, see again the document chapter 4.2.1

example:

btw. for questions concerning working with the App Inventor or extensions, please use the Open Source Group in future https://groups.google.com/forum/#!forum/app-inventor-open-source-dev

--
Do you think I should open a new thread in this other Google Group to propose my work ?

--
This is the right forum to show what you have made.
The developers forum would be the right place to ask questions when you have a problem creating your extension, but anyway, show there what you have done!

--
I may have found a small bug that crashes app inventor companion.
The app crashes when I call the methode disconnect the whole app crashes.
It does not matter if I use the button click or remote connection close.

And another problem I found is that when you consecutive send data to fast it wil be send as a single line.
For instance if you send a number 2 and 5 it wil be send as 25. 

--
Thanks for your report,

I'm currently triing to solve the first problem (I think it's because of the closing of the socket while continuing reading the inputstream ...

Will watch for the second problem as soon as possible then.

--
Ok, new version (0.3) that solves the disconnect problem (and also put an icon for the extension).

But I can't redo the second bug that send two data as a single line, can you give me the program you have done to produce this bug ?

--
apk files are not allowed in this forum, see also the 

I removed it for you.
You might want to provide the aia file instead. Thank you.

--
Yes, that's right, I'll give aia file instead when I'll be releasing next version.

--

New Version : 0.4

Changelog :
- You are now able to send non ascii data, just modify the hexaStringMode to true and send "303132" to send characters 012. Received data will also be translated to an hexa string.

Cheers, 

MoiCJarod

New Version : 0.4.1

Changelog :
- name of the extension changed to distinguish from Java library
- source file indentation reworked
- bug fixed :
    - extension was concatenating messages received. fixed
    - problem in detecting non hexa characters in hexa mode : fixed

--


댓글 없음:

댓글 쓰기