byte array passing to swhx

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

byte array passing to swhx

Stephen Anson
Hi,

I have a swf that is wrapped in swhx.
I also have another application that is sending binary data to a neko ServerLoop over a socket connection.(inside the swhx wrapper.)

However I'm struggling to get the data thru to the swf using the standard Connection method i.e. cnx.someMethod.call([mybinarydata])
If I send it it arrives as a series of characters but I'm not sure how they map to the original binary data.

Is there a way to do this, or do I need to send an array of Ints ?

Any help really appreciated as I'm pulling my hair out on this one! 

-thanks Steve

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

laurence taylor
I haven't used it but haxe.io.Bytes.ofString() might do it.

On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:

> Hi,
> I have a swf that is wrapped in swhx.
> I also have another application that is sending binary data to a neko
> ServerLoop over a socket connection.(inside the swhx wrapper.)
> However I'm struggling to get the data thru to the swf using the standard
> Connection method i.e. cnx.someMethod.call([mybinarydata])
> If I send it it arrives as a series of characters but I'm not sure how they
> map to the original binary data.
> Is there a way to do this, or do I need to send an array of Ints ?
> Any help really appreciated as I'm pulling my hair out on this one!
> -thanks Steve
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Hi,

Bytes.ofString( some string) returns a Bytes object, - I already have  that - i'm trying to get the Bytes object over  to flash over the swhx connection.

I have tried Bytes.toString but when i send that over the Connection it reports an error in the Unserializer.

Incidentally the other way around: from flash byte array to neko, it seems to work fine. 

So this works ( the byte array is auto converted to a string haxe/swhx somewhere)

Bytes.ofString( my bytearray string over swhx connection);


It seems a shame to have to loop the bytes to create an array to send back .....

thanks Steve
 
On 2 Jun 2011, at 16:53, laurence taylor wrote:

I haven't used it but haxe.io.Bytes.ofString() might do it.

On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
Hi,
I have a swf that is wrapped in swhx.
I also have another application that is sending binary data to a neko
ServerLoop over a socket connection.(inside the swhx wrapper.)
However I'm struggling to get the data thru to the swf using the standard
Connection method i.e. cnx.someMethod.call([mybinarydata])
If I send it it arrives as a series of characters but I'm not sure how they
map to the original binary data.
Is there a way to do this, or do I need to send an array of Ints ?
Any help really appreciated as I'm pulling my hair out on this one!
-thanks Steve
Steve Anson
Flash Developer
Actionscript Solutions Ltd.
[hidden email]




--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Hi,

Also is it possible that a later build of haxe could fix this issue? I if is one?

thanks Steve

On 2 Jun 2011, at 17:08, Stephen Anson wrote:

Hi,

Bytes.ofString( some string) returns a Bytes object, - I already have  that - i'm trying to get the Bytes object over  to flash over the swhx connection.

I have tried Bytes.toString but when i send that over the Connection it reports an error in the Unserializer.

Incidentally the other way around: from flash byte array to neko, it seems to work fine. 

So this works ( the byte array is auto converted to a string haxe/swhx somewhere)

Bytes.ofString( my bytearray string over swhx connection);


It seems a shame to have to loop the bytes to create an array to send back .....

thanks Steve
 
On 2 Jun 2011, at 16:53, laurence taylor wrote:

I haven't used it but haxe.io.Bytes.ofString() might do it.

On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
Hi,
I have a swf that is wrapped in swhx.
I also have another application that is sending binary data to a neko
ServerLoop over a socket connection.(inside the swhx wrapper.)
However I'm struggling to get the data thru to the swf using the standard
Connection method i.e. cnx.someMethod.call([mybinarydata])
If I send it it arrives as a series of characters but I'm not sure how they
map to the original binary data.
Is there a way to do this, or do I need to send an array of Ints ?
Any help really appreciated as I'm pulling my hair out on this one!
-thanks Steve
Steve Anson
Flash Developer
Actionscript Solutions Ltd.
[hidden email]




--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

laurence taylor
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:

> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Cauê W.
ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Fwd: [haXe] byte array passing to swhx

Stephen Anson
Hi All,

The options I see are:
1. send and array of ints, to flash
performance may be an issue as back in flash i have to convert the 'array int string' to an array, push that into a byte array in order to reconstruct my object

2. Bypass swhx Connection and use a Binary socket 
shame as its already configured with a swhx Connection

3. figure out how to convert the Bytes string back to a byte array 
no idea where to start


Any ideas out there why this is so painful?

thanks Steve

Begin forwarded message:

From: Stephen Anson <[hidden email]>
Date: 3 June 2011 09:01:41 GMT+01:00
To: The haXe compiler list <[hidden email]>
Subject: Re: [haXe] byte array passing to swhx
Reply-To: The haXe compiler list <[hidden email]>

Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Cauê W.
if you send the bytes, it will convert as a string but when you unserialize it, it will convert it back to bytes again. So I don't get what seems to be the problem?

2011/6/3 Stephen Anson <[hidden email]>
Hi All,

The options I see are:
1. send and array of ints, to flash
performance may be an issue as back in flash i have to convert the 'array int string' to an array, push that into a byte array in order to reconstruct my object

2. Bypass swhx Connection and use a Binary socket 
shame as its already configured with a swhx Connection

3. figure out how to convert the Bytes string back to a byte array 
no idea where to start


Any ideas out there why this is so painful?

thanks Steve

Begin forwarded message:

From: Stephen Anson <[hidden email]>
Date: 3 June 2011 09:01:41 GMT+01:00
To: The haXe compiler list <[hidden email]>
Subject: Re: [haXe] byte array passing to swhx
Reply-To: The haXe compiler list <[hidden email]>

Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Just to clarify, I'm doing this:
1. sending an object ( typed ) over a socket as bytes to a neko Server loop from flash movie 'A'
2. sending those bytes on to flash movie 'B' over swhx Connection.

In movie 'B', I then want to get the bytes back again in order to recreate my object using 

bytearray.readObject()

Yes it does convert to a string, I then tried taking that string and doing this in flash:

bytearray.writeUTFBytes(stringfromhaxe); 

however the bytes that I trace out are nothing like the original bytes that were sent

does that explain it?

Incidentally - 1. does work but I suspect there is a better way!!

thanks Steve

On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

if you send the bytes, it will convert as a string but when you unserialize it, it will convert it back to bytes again. So I don't get what seems to be the problem?

2011/6/3 Stephen Anson <[hidden email]>
Hi All,

The options I see are:
1. send and array of ints, to flash
performance may be an issue as back in flash i have to convert the 'array int string' to an array, push that into a byte array in order to reconstruct my object

2. Bypass swhx Connection and use a Binary socket 
shame as its already configured with a swhx Connection

3. figure out how to convert the Bytes string back to a byte array 
no idea where to start


Any ideas out there why this is so painful?

thanks Steve

Begin forwarded message:

From: Stephen Anson <[hidden email]>
Date: 3 June 2011 09:01:41 GMT+01:00
To: The haXe compiler list <[hidden email]>
Subject: Re: [haXe] byte array passing to swhx
Reply-To: The haXe compiler list <[hidden email]>

Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Cauê W.
when you say you are sending the object as bytes, are you sending it as haxe.io.Bytes or as a ByteArray?

unserialization/serialization should run transparent to you in this case, so it really seems quite strange that you are receiving a string. If you are sending it as haxe.io.Bytes, I can't really think of how you are receving a string. Can  you post some of your code?

Cheers!
Caue

2011/6/4 Stephen Anson <[hidden email]>
Just to clarify, I'm doing this:
1. sending an object ( typed ) over a socket as bytes to a neko Server loop from flash movie 'A'
2. sending those bytes on to flash movie 'B' over swhx Connection.

In movie 'B', I then want to get the bytes back again in order to recreate my object using 

bytearray.readObject()

Yes it does convert to a string, I then tried taking that string and doing this in flash:

bytearray.writeUTFBytes(stringfromhaxe); 

however the bytes that I trace out are nothing like the original bytes that were sent

does that explain it?

Incidentally - 1. does work but I suspect there is a better way!!

thanks Steve

On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

if you send the bytes, it will convert as a string but when you unserialize it, it will convert it back to bytes again. So I don't get what seems to be the problem?

2011/6/3 Stephen Anson <[hidden email]>
Hi All,

The options I see are:
1. send and array of ints, to flash
performance may be an issue as back in flash i have to convert the 'array int string' to an array, push that into a byte array in order to reconstruct my object

2. Bypass swhx Connection and use a Binary socket 
shame as its already configured with a swhx Connection

3. figure out how to convert the Bytes string back to a byte array 
no idea where to start


Any ideas out there why this is so painful?

thanks Steve

Begin forwarded message:

From: Stephen Anson <[hidden email]>
Date: 3 June 2011 09:01:41 GMT+01:00
To: The haXe compiler list <[hidden email]>
Subject: Re: [haXe] byte array passing to swhx
Reply-To: The haXe compiler list <[hidden email]>

Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Hi, 

thanks for giving this some attention!

// -- Movie A sends bytes using a binary Socket
// callWrapper is an object with targ:int id, func:String name and arg:* properties

callWrapper.targ = CommsConstants.TARG_BASE_SELF_PACED;
callWrapper.func = func;
callWrapper.arg = arg;
outSock.writeBytes( byteArrayConverter(callWrapper) ); // this creates a byte array and writes the object to it
outSock.flush();

// -- override from ServerLoop

override public function processClientData( d : ClientData, buf : haxe.io.Bytes, bufpos : Int, buflen : Int ) 
    {
ShareData.remoteComms.setRemoteManagerData(buf );
return buflen;
    }

// -- RemoteComms object sends to flash Movie B over swhx.Connection

public function setRemoteManagerData( buf:Bytes)
{
cnx.onRemoteManData.call([buf.getData()]); // when i send buf it ends up in flash as a string, when I send a buf.getData() an error occurs in UnSerializer
}

// -- movie B
public function onRemoteManData(data):void
{
// trace out data
}

//
I also notice that if i send a bytearray out over swhx.Connection it ends up in haxe as a String.
I am using swhx 1.2.0, haxe was recent download from google code.


thanks Steve

On 4 Jun 2011, at 14:36, Cauê Waneck wrote:

when you say you are sending the object as bytes, are you sending it as haxe.io.Bytes or as a ByteArray?

unserialization/serialization should run transparent to you in this case, so it really seems quite strange that you are receiving a string. If you are sending it as haxe.io.Bytes, I can't really think of how you are receving a string. Can  you post some of your code?

Cheers!
Caue

2011/6/4 Stephen Anson <[hidden email]>
Just to clarify, I'm doing this:
1. sending an object ( typed ) over a socket as bytes to a neko Server loop from flash movie 'A'
2. sending those bytes on to flash movie 'B' over swhx Connection.

In movie 'B', I then want to get the bytes back again in order to recreate my object using 

bytearray.readObject()

Yes it does convert to a string, I then tried taking that string and doing this in flash:

bytearray.writeUTFBytes(stringfromhaxe); 

however the bytes that I trace out are nothing like the original bytes that were sent

does that explain it?

Incidentally - 1. does work but I suspect there is a better way!!

thanks Steve

On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

if you send the bytes, it will convert as a string but when you unserialize it, it will convert it back to bytes again. So I don't get what seems to be the problem?

2011/6/3 Stephen Anson <[hidden email]>
Hi All,

The options I see are:
1. send and array of ints, to flash
performance may be an issue as back in flash i have to convert the 'array int string' to an array, push that into a byte array in order to reconstruct my object

2. Bypass swhx Connection and use a Binary socket 
shame as its already configured with a swhx Connection

3. figure out how to convert the Bytes string back to a byte array 
no idea where to start


Any ideas out there why this is so painful?

thanks Steve

Begin forwarded message:

From: Stephen Anson <[hidden email]>
Date: 3 June 2011 09:01:41 GMT+01:00
To: The haXe compiler list <[hidden email]>
Subject: Re: [haXe] byte array passing to swhx
Reply-To: The haXe compiler list <[hidden email]>

Hi,

The problem is how to serialize the Bytes in order to get it back to the swf over a swhx Connection
If I send the bytearray directly it can't serialize it I get this error:

Called from c:\haxe/std/haxe/Serializer.hx line 393
Called from c:\haxe/std/haxe/Serializer.hx line 208
Called from swhx/Connection.hx line 67

If I send the Bytes it converts to a string and sends that.
If I then writeUTFBytes from the string back in flash bytearray and read the bytes they are nothing like the original bytes

Any ideas?

thanks Steve

On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

ByteArray is the flash implementation of haxe.io.BytesData . You can convert back and forth ByteArray to Bytes like this: Bytes.fromData(myByteArray) and myBytesObject.getData()

cheers!
Caue

2011/6/2 laurence taylor <[hidden email]>
Have you checked haxe on google code, the mail archives and the changes.txt?

On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson <[hidden email]> wrote:
> Hi,
> Also is it possible that a later build of haxe could fix this issue? I if is
> one?
> thanks Steve
> On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>
> Hi,
> Bytes.ofString( some string) returns a Bytes object, - I already have  that
> - i'm trying to get the Bytes object over  to flash over the swhx
> connection.
> I have tried Bytes.toString but when i send that over the Connection it
> reports an error in the Unserializer.
> Incidentally the other way around: from flash byte array to neko, it seems
> to work fine.
> So this works ( the byte array is auto converted to a string haxe/swhx
> somewhere)
> Bytes.ofString( my bytearray string over swhx connection);
>
> It seems a shame to have to loop the bytes to create an array to send back
> .....
> thanks Steve
>
> On 2 Jun 2011, at 16:53, laurence taylor wrote:
>
> I haven't used it but haxe.io.Bytes.ofString() might do it.
>
> On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson <[hidden email]> wrote:
>
> Hi,
>
> I have a swf that is wrapped in swhx.
>
> I also have another application that is sending binary data to a neko
>
> ServerLoop over a socket connection.(inside the swhx wrapper.)
>
> However I'm struggling to get the data thru to the swf using the standard
>
> Connection method i.e. cnx.someMethod.call([mybinarydata])
>
> If I send it it arrives as a series of characters but I'm not sure how they
>
> map to the original binary data.
>
> Is there a way to do this, or do I need to send an array of Ints ?
>
> Any help really appreciated as I'm pulling my hair out on this one!
>
> -thanks Steve
>
> Steve Anson
>
> Flash Developer
>
> Actionscript Solutions Ltd.
>
> [hidden email]
>
>
>
>
> --
>
> haXe - an open source web programming language
>
> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email]
>
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.




--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

go2ghana
Am 04.06.2011 18:15, schrieb Stephen Anson:

> Hi,
>
> thanks for giving this some attention!
>
> // -- Movie A sends bytes using a binary Socket
> // callWrapper is an object with targ:int id, func:String name and
> arg:* properties
>
> callWrapper.targ = CommsConstants.TARG_BASE_SELF_PACED;
> callWrapper.func = func;
> callWrapper.arg = arg;
> outSock.writeBytes( byteArrayConverter(callWrapper) ); // this creates
> a byte array and writes the object to it
> outSock.flush();
>
> // -- override from ServerLoop
>
> override public function processClientData( d : ClientData, buf :
> haxe.io.Bytes, bufpos : Int, buflen : Int )
>     {
> ShareData.remoteComms.setRemoteManagerData(buf );
> return buflen;
>     }
>
> // -- RemoteComms object sends to flash Movie B over swhx.Connection
>
> public function setRemoteManagerData( buf:Bytes)
> {
> cnx.onRemoteManData.call([buf.getData()]); // when i send buf it ends
> up in flash as a string, when I send a buf.getData() an error occurs
> in UnSerializer
> }
>
> // -- movie B
> public function onRemoteManData(data):void
> {
> // trace out data
> }
>
> //
> I also notice that if i send a bytearray out over swhx.Connection it
> ends up in haxe as a String.
> I am using swhx 1.2.0, haxe was recent download from google code.
>
>
> thanks Steve
>
> On 4 Jun 2011, at 14:36, Cauê Waneck wrote:
>
>> when you say you are sending the object as bytes, are you sending it
>> as haxe.io.Bytes or as a ByteArray?
>>
>> unserialization/serialization should run transparent to you in this
>> case, so it really seems quite strange that you are receiving a
>> string. If you are sending it as haxe.io.Bytes, I can't really think
>> of how you are receving a string. Can  you post some of your code?
>>
>> Cheers!
>> Caue
>>
>> 2011/6/4 Stephen Anson <[hidden email] <mailto:[hidden email]>>
>>
>>     Just to clarify, I'm doing this:
>>     1. sending an object ( typed ) over a socket as bytes to a neko
>>     Server loop from flash movie 'A'
>>     2. sending those bytes on to flash movie 'B' over swhx Connection.
>>
>>     In movie 'B', I then want to get the bytes back again in order to
>>     recreate my object using
>>
>>     bytearray.readObject()
>>
>>     Yes it does convert to a string, I then tried taking that string
>>     and doing this in flash:
>>
>>     bytearray.writeUTFBytes(stringfromhaxe);
>>
>>     however the bytes that I trace out are nothing like the original
>>     bytes that were sent
>>
>>     does that explain it?
>>
>>     Incidentally - 1. does work but I suspect there is a better way!!
>>
>>     thanks Steve
>>
>>     On 3 Jun 2011, at 13:54, Cauê Waneck wrote:
>>
>>>     if you send the bytes, it will convert as a string but when you
>>>     unserialize it, it will convert it back to bytes again. So I
>>>     don't get what seems to be the problem?
>>>
>>>     2011/6/3 Stephen Anson <[hidden email] <mailto:[hidden email]>>
>>>
>>>         Hi All,
>>>
>>>         The options I see are:
>>>         1. send and array of ints, to flash
>>>         performance may be an issue as back in flash i have to
>>>         convert the 'array int string' to an array, push that into a
>>>         byte array in order to reconstruct my object
>>>
>>>         2. Bypass swhx Connection and use a Binary socket
>>>         shame as its already configured with a swhx Connection
>>>
>>>         3. figure out how to convert the Bytes string back to a byte
>>>         array
>>>         no idea where to start
>>>
>>>
>>>         Any ideas out there why this is so painful?
>>>
>>>         thanks Steve
>>>
>>>         Begin forwarded message:
>>>
>>>>         *From: *Stephen Anson <[hidden email]
>>>>         <mailto:[hidden email]>>
>>>>         *Date: *3 June 2011 09:01:41 GMT+01:00
>>>>         *To: *The haXe compiler list <[hidden email]
>>>>         <mailto:[hidden email]>>
>>>>         *Subject: **Re: [haXe] byte array passing to swhx*
>>>>         *Reply-To: *The haXe compiler list
>>>>         <[hidden email]
>>>>         <mailto:[hidden email]>>
>>>>
>>>>         Hi,
>>>>
>>>>         The problem is how to serialize the Bytes in order to get
>>>>         it back to the swf over a swhx Connection
>>>>         If I send the bytearray directly it can't serialize it I
>>>>         get this error:
>>>>
>>>>         Called from c:\haxe/std/haxe/Serializer.hx line 393
>>>>         Called from c:\haxe/std/haxe/Serializer.hx line 208
>>>>         Called from swhx/Connection.hx line 67
>>>>
>>>>         If I send the Bytes it converts to a string and sends that.
>>>>         If I then writeUTFBytes from the string back in flash
>>>>         bytearray and read the bytes they are nothing like the
>>>>         original bytes
>>>>
>>>>         Any ideas?
>>>>
>>>>         thanks Steve
>>>>
>>>>         On 2 Jun 2011, at 22:44, Cauê Waneck wrote:
>>>>
>>>>>         ByteArray is the flash implementation of haxe.io.BytesData
>>>>>         . You can convert back and forth ByteArray to Bytes like
>>>>>         this: Bytes.fromData(myByteArray) and myBytesObject.getData()
>>>>>
>>>>>         cheers!
>>>>>         Caue
>>>>>
>>>>>         2011/6/2 laurence taylor <[hidden email]
>>>>>         <mailto:[hidden email]>>
>>>>>
>>>>>             Have you checked haxe on google code, the mail
>>>>>             archives and the changes.txt?
>>>>>
>>>>>             On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson
>>>>>             <[hidden email] <mailto:[hidden email]>> wrote:
>>>>>             > Hi,
>>>>>             > Also is it possible that a later build of haxe could
>>>>>             fix this issue? I if is
>>>>>             > one?
>>>>>             > thanks Steve
>>>>>             > On 2 Jun 2011, at 17:08, Stephen Anson wrote:
>>>>>             >
>>>>>             > Hi,
>>>>>             > Bytes.ofString( some string) returns a Bytes object,
>>>>>             - I already have  that
>>>>>             > - i'm trying to get the Bytes object over  to flash
>>>>>             over the swhx
>>>>>             > connection.
>>>>>             > I have tried Bytes.toString but when i send that
>>>>>             over the Connection it
>>>>>             > reports an error in the Unserializer.
>>>>>             > Incidentally the other way around: from flash byte
>>>>>             array to neko, it seems
>>>>>             > to work fine.
>>>>>             > So this works ( the byte array is auto converted to
>>>>>             a string haxe/swhx
>>>>>             > somewhere)
>>>>>             > Bytes.ofString( my bytearray string over swhx
>>>>>             connection);
>>>>>             >
>>>>>             > It seems a shame to have to loop the bytes to create
>>>>>             an array to send back
>>>>>             > .....
>>>>>             > thanks Steve
>>>>>             >
>>>>>             > On 2 Jun 2011, at 16:53, laurence taylor wrote:
>>>>>             >
>>>>>             > I haven't used it but haxe.io.Bytes.ofString() might
>>>>>             do it.
>>>>>             >
>>>>>             > On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson
>>>>>             <[hidden email] <mailto:[hidden email]>> wrote:
>>>>>             >
>>>>>             > Hi,
>>>>>             >
>>>>>             > I have a swf that is wrapped in swhx.
>>>>>             >
>>>>>             > I also have another application that is sending
>>>>>             binary data to a neko
>>>>>             >
>>>>>             > ServerLoop over a socket connection.(inside the swhx
>>>>>             wrapper.)
>>>>>             >
>>>>>             > However I'm struggling to get the data thru to the
>>>>>             swf using the standard
>>>>>             >
>>>>>             > Connection method i.e.
>>>>>             cnx.someMethod.call([mybinarydata])
>>>>>             >
>>>>>             > If I send it it arrives as a series of characters
>>>>>             but I'm not sure how they
>>>>>             >
>>>>>             > map to the original binary data.
>>>>>             >
>>>>>             > Is there a way to do this, or do I need to send an
>>>>>             array of Ints ?
>>>>>             >
>>>>>             > Any help really appreciated as I'm pulling my hair
>>>>>             out on this one!
>>>>>             >
>>>>>             > -thanks Steve
>>>>>             >
>>>>>             > Steve Anson
>>>>>             >
>>>>>             > Flash Developer
>>>>>             >
>>>>>             > Actionscript Solutions Ltd.
>>>>>             >
>>>>>             > [hidden email] <mailto:[hidden email]>
>>>>>             >
>>>>>             >
>>>>>             >
>>>>>             >
>>>>>             > --
>>>>>             >
>>>>>             > haXe - an open source web programming language
>>>>>             >
>>>>>             > http://haxe.org <http://haxe.org/>
>>>>>             >
>>>>>             >
>>>>>             > --
>>>>>             > haXe - an open source web programming language
>>>>>             > http://haxe.org <http://haxe.org/>
>>>>>             >
>>>>>             >
>>>>>             > Steve Anson
>>>>>             > Flash Developer
>>>>>             > Actionscript Solutions Ltd.
>>>>>             > [hidden email] <mailto:[hidden email]>
>>>>>             >
>>>>>             >
>>>>>             >
>>>>>             > --
>>>>>             > haXe - an open source web programming language
>>>>>             > http://haxe.org <http://haxe.org/>
>>>>>             >
>>>>>             > Steve Anson
>>>>>             > Flash Developer
>>>>>             > Actionscript Solutions Ltd.
>>>>>             > [hidden email] <mailto:[hidden email]>
>>>>>             >
>>>>>             >
>>>>>             >
>>>>>             >
>>>>>             > --
>>>>>             > haXe - an open source web programming language
>>>>>             > http://haxe.org <http://haxe.org/>
>>>>>             >
>>>>>
>>>>>             --
>>>>>             haXe - an open source web programming language
>>>>>             http://haxe.org <http://haxe.org/>
>>>>>
>>>>>
>>>>>         --
>>>>>         haXe - an open source web programming language
>>>>>         http://haxe.org <http://haxe.org/>
>>>>
>>>>         Steve Anson
>>>>         Flash Developer
>>>>         Actionscript Solutions Ltd.
>>>>         [hidden email] <mailto:[hidden email]>
>>>>
>>>>
>>>>
>>>>
>>>>         --
>>>>         haXe - an open source web programming language
>>>>         http://haxe.org <http://haxe.org/>
>>>
>>>         Steve Anson
>>>         Flash Developer
>>>         Actionscript Solutions Ltd.
>>>         [hidden email] <mailto:[hidden email]>
>>>
>>>
>>>
>>>
>>>
>>>         --
>>>         haXe - an open source web programming language
>>>         http://haxe.org <http://haxe.org/>
>>>
>>>
>>>     --
>>>     haXe - an open source web programming language
>>>     http://haxe.org <http://haxe.org/>
>>
>>     Steve Anson
>>     Flash Developer
>>     Actionscript Solutions Ltd.
>>     [hidden email] <mailto:[hidden email]>
>>
>>
>>
>>
>>
>>     --
>>     haXe - an open source web programming language
>>     http://haxe.org <http://haxe.org/>
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
> Steve Anson
> Flash Developer
> Actionscript Solutions Ltd.
> [hidden email] <mailto:[hidden email]>
>
>
>
>
Hi,
am just guessing that this might happen because the call to
buf.getData() on neko returns a NativeString ?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson

On 4 Jun 2011, at 18:27, Axel Huizinga wrote:

Am 04.06.2011 18:15, schrieb Stephen Anson:
Hi,

thanks for giving this some attention!

// -- Movie A sends bytes using a binary Socket
// callWrapper is an object with targ:int id, func:String name and arg:* properties

callWrapper.targ = CommsConstants.TARG_BASE_SELF_PACED;
callWrapper.func = func;
callWrapper.arg = arg;
outSock.writeBytes( byteArrayConverter(callWrapper) ); // this creates a byte array and writes the object to it
outSock.flush();

// -- override from ServerLoop

override public function processClientData( d : ClientData, buf : haxe.io.Bytes, bufpos : Int, buflen : Int )
   {
ShareData.remoteComms.setRemoteManagerData(buf );
return buflen;
   }

// -- RemoteComms object sends to flash Movie B over swhx.Connection

public function setRemoteManagerData( buf:Bytes)
{
cnx.onRemoteManData.call([buf.getData()]); // when i send buf it ends up in flash as a string, when I send a buf.getData() an error occurs in UnSerializer
}

// -- movie B
public function onRemoteManData(data):void
{
// trace out data
}

//
I also notice that if i send a bytearray out over swhx.Connection it ends up in haxe as a String.
I am using swhx 1.2.0, haxe was recent download from google code.


thanks Steve

On 4 Jun 2011, at 14:36, Cauê Waneck wrote:

when you say you are sending the object as bytes, are you sending it as haxe.io.Bytes or as a ByteArray?

unserialization/serialization should run transparent to you in this case, so it really seems quite strange that you are receiving a string. If you are sending it as haxe.io.Bytes, I can't really think of how you are receving a string. Can  you post some of your code?

Cheers!
Caue

2011/6/4 Stephen Anson <[hidden email] <[hidden email]>>

   Just to clarify, I'm doing this:
   1. sending an object ( typed ) over a socket as bytes to a neko
   Server loop from flash movie 'A'
   2. sending those bytes on to flash movie 'B' over swhx Connection.

   In movie 'B', I then want to get the bytes back again in order to
   recreate my object using

   bytearray.readObject()

   Yes it does convert to a string, I then tried taking that string
   and doing this in flash:

   bytearray.writeUTFBytes(stringfromhaxe);

   however the bytes that I trace out are nothing like the original
   bytes that were sent

   does that explain it?

   Incidentally - 1. does work but I suspect there is a better way!!

   thanks Steve

   On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

   if you send the bytes, it will convert as a string but when you
   unserialize it, it will convert it back to bytes again. So I
   don't get what seems to be the problem?

   2011/6/3 Stephen Anson <[hidden email] <[hidden email]>>

       Hi All,

       The options I see are:
       1. send and array of ints, to flash
       performance may be an issue as back in flash i have to
       convert the 'array int string' to an array, push that into a
       byte array in order to reconstruct my object

       2. Bypass swhx Connection and use a Binary socket
       shame as its already configured with a swhx Connection

       3. figure out how to convert the Bytes string back to a byte
       array
       no idea where to start


       Any ideas out there why this is so painful?

       thanks Steve

       Begin forwarded message:

       *From: *Stephen Anson <[hidden email]
       <[hidden email]>>
       *Date: *3 June 2011 09:01:41 GMT+01:00
       *To: *The haXe compiler list <[hidden email]
       <[hidden email]>>
       *Subject: **Re: [haXe] byte array passing to swhx*
       *Reply-To: *The haXe compiler list
       <[hidden email]
       <[hidden email]>>

       Hi,

       The problem is how to serialize the Bytes in order to get
       it back to the swf over a swhx Connection
       If I send the bytearray directly it can't serialize it I
       get this error:

       Called from c:\haxe/std/haxe/Serializer.hx line 393
       Called from c:\haxe/std/haxe/Serializer.hx line 208
       Called from swhx/Connection.hx line 67

       If I send the Bytes it converts to a string and sends that.
       If I then writeUTFBytes from the string back in flash
       bytearray and read the bytes they are nothing like the
       original bytes

       Any ideas?

       thanks Steve

       On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

       ByteArray is the flash implementation of haxe.io.BytesData
       . You can convert back and forth ByteArray to Bytes like
       this: Bytes.fromData(myByteArray) and myBytesObject.getData()

       cheers!
       Caue

       2011/6/2 laurence taylor <[hidden email]
       <[hidden email]>>

           Have you checked haxe on google code, the mail
           archives and the changes.txt?

           On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           > Hi,
           > Also is it possible that a later build of haxe could
           fix this issue? I if is
           > one?
           > thanks Steve
           > On 2 Jun 2011, at 17:08, Stephen Anson wrote:
           >
           > Hi,
           > Bytes.ofString( some string) returns a Bytes object,
           - I already have  that
           > - i'm trying to get the Bytes object over  to flash
           over the swhx
           > connection.
           > I have tried Bytes.toString but when i send that
           over the Connection it
           > reports an error in the Unserializer.
           > Incidentally the other way around: from flash byte
           array to neko, it seems
           > to work fine.
           > So this works ( the byte array is auto converted to
           a string haxe/swhx
           > somewhere)
           > Bytes.ofString( my bytearray string over swhx
           connection);
           >
           > It seems a shame to have to loop the bytes to create
           an array to send back
           > .....
           > thanks Steve
           >
           > On 2 Jun 2011, at 16:53, laurence taylor wrote:
           >
           > I haven't used it but haxe.io.Bytes.ofString() might
           do it.
           >
           > On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           >
           > Hi,
           >
           > I have a swf that is wrapped in swhx.
           >
           > I also have another application that is sending
           binary data to a neko
           >
           > ServerLoop over a socket connection.(inside the swhx
           wrapper.)
           >
           > However I'm struggling to get the data thru to the
           swf using the standard
           >
           > Connection method i.e.
           cnx.someMethod.call([mybinarydata])
           >
           > If I send it it arrives as a series of characters
           but I'm not sure how they
           >
           > map to the original binary data.
           >
           > Is there a way to do this, or do I need to send an
           array of Ints ?
           >
           > Any help really appreciated as I'm pulling my hair
           out on this one!
           >
           > -thanks Steve
           >
           > Steve Anson
           >
           > Flash Developer
           >
           > Actionscript Solutions Ltd.
           >
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           >
           > haXe - an open source web programming language
           >
           > http://haxe.org <http://haxe.org/>
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >

           --
           haXe - an open source web programming language
           http://haxe.org <http://haxe.org/>


       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>




       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>





       --
       haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>


   --     haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>

   Steve Anson
   Flash Developer
   Actionscript Solutions Ltd.
   [hidden email] <[hidden email]>





   --
   haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>


--
haXe - an open source web programming language
http://haxe.org

Steve Anson
Flash Developer
Actionscript Solutions Ltd.
[hidden email] <[hidden email]>




Hi,
am just guessing that this might happen because the call to
buf.getData() on neko returns a NativeString ?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org


shouldn't it return a Bytes object?

If not how do I return that data back to flash via swhx.Connection?
 

At the moment I'm converting to an array of ints and sending that, this is actually sent as a comma deliminated string, which has to be split etc
seems very messy.

thanks Steve


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Cauê W.
Hey stephen, it seems that you are connecting through raw sockets, instead of using haxe remoting. Is that it? I've never used more than one flash client with swhx, but swhx has its own communication protocol. Have you tried that? It works pretty well.
Anyway, the Bytes you receive from processClientData aren't the actual bytes you sent. They are serialized. If you want to use sockets to communicate, have a look at ThreadRemotingServer and this example : http://haxe.org/doc/flash/chat  . Basically, you'll have to define a context with a function that will receive the bytes variable and send it to the other client.

Hope it helps
Cheers!
Caue



2011/6/4 Stephen Anson <[hidden email]>

On 4 Jun 2011, at 18:27, Axel Huizinga wrote:

Am 04.06.2011 18:15, schrieb Stephen Anson:
Hi,

thanks for giving this some attention!

// -- Movie A sends bytes using a binary Socket
// callWrapper is an object with targ:int id, func:String name and arg:* properties

callWrapper.targ = CommsConstants.TARG_BASE_SELF_PACED;
callWrapper.func = func;
callWrapper.arg = arg;
outSock.writeBytes( byteArrayConverter(callWrapper) ); // this creates a byte array and writes the object to it
outSock.flush();

// -- override from ServerLoop

override public function processClientData( d : ClientData, buf : haxe.io.Bytes, bufpos : Int, buflen : Int )
   {
ShareData.remoteComms.setRemoteManagerData(buf );
return buflen;
   }

// -- RemoteComms object sends to flash Movie B over swhx.Connection

public function setRemoteManagerData( buf:Bytes)
{
cnx.onRemoteManData.call([buf.getData()]); // when i send buf it ends up in flash as a string, when I send a buf.getData() an error occurs in UnSerializer
}

// -- movie B
public function onRemoteManData(data):void
{
// trace out data
}

//
I also notice that if i send a bytearray out over swhx.Connection it ends up in haxe as a String.
I am using swhx 1.2.0, haxe was recent download from google code.


thanks Steve

On 4 Jun 2011, at 14:36, Cauê Waneck wrote:

when you say you are sending the object as bytes, are you sending it as haxe.io.Bytes or as a ByteArray?

unserialization/serialization should run transparent to you in this case, so it really seems quite strange that you are receiving a string. If you are sending it as haxe.io.Bytes, I can't really think of how you are receving a string. Can  you post some of your code?

Cheers!
Caue

2011/6/4 Stephen Anson <[hidden email] <[hidden email]>>

   Just to clarify, I'm doing this:
   1. sending an object ( typed ) over a socket as bytes to a neko
   Server loop from flash movie 'A'
   2. sending those bytes on to flash movie 'B' over swhx Connection.

   In movie 'B', I then want to get the bytes back again in order to
   recreate my object using

   bytearray.readObject()

   Yes it does convert to a string, I then tried taking that string
   and doing this in flash:

   bytearray.writeUTFBytes(stringfromhaxe);

   however the bytes that I trace out are nothing like the original
   bytes that were sent

   does that explain it?

   Incidentally - 1. does work but I suspect there is a better way!!

   thanks Steve

   On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

   if you send the bytes, it will convert as a string but when you
   unserialize it, it will convert it back to bytes again. So I
   don't get what seems to be the problem?

   2011/6/3 Stephen Anson <[hidden email] <[hidden email]>>

       Hi All,

       The options I see are:
       1. send and array of ints, to flash
       performance may be an issue as back in flash i have to
       convert the 'array int string' to an array, push that into a
       byte array in order to reconstruct my object

       2. Bypass swhx Connection and use a Binary socket
       shame as its already configured with a swhx Connection

       3. figure out how to convert the Bytes string back to a byte
       array
       no idea where to start


       Any ideas out there why this is so painful?

       thanks Steve

       Begin forwarded message:

       *From: *Stephen Anson <[hidden email]
       <[hidden email]>>
       *Date: *3 June 2011 09:01:41 GMT+01:00
       *To: *The haXe compiler list <[hidden email]
       <[hidden email]>>
       *Subject: **Re: [haXe] byte array passing to swhx*
       *Reply-To: *The haXe compiler list
       <[hidden email]
       <[hidden email]>>

       Hi,

       The problem is how to serialize the Bytes in order to get
       it back to the swf over a swhx Connection
       If I send the bytearray directly it can't serialize it I
       get this error:

       Called from c:\haxe/std/haxe/Serializer.hx line 393
       Called from c:\haxe/std/haxe/Serializer.hx line 208
       Called from swhx/Connection.hx line 67

       If I send the Bytes it converts to a string and sends that.
       If I then writeUTFBytes from the string back in flash
       bytearray and read the bytes they are nothing like the
       original bytes

       Any ideas?

       thanks Steve

       On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

       ByteArray is the flash implementation of haxe.io.BytesData
       . You can convert back and forth ByteArray to Bytes like
       this: Bytes.fromData(myByteArray) and myBytesObject.getData()

       cheers!
       Caue

       2011/6/2 laurence taylor <[hidden email]
       <[hidden email]>>

           Have you checked haxe on google code, the mail
           archives and the changes.txt?

           On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           > Hi,
           > Also is it possible that a later build of haxe could
           fix this issue? I if is
           > one?
           > thanks Steve
           > On 2 Jun 2011, at 17:08, Stephen Anson wrote:
           >
           > Hi,
           > Bytes.ofString( some string) returns a Bytes object,
           - I already have  that
           > - i'm trying to get the Bytes object over  to flash
           over the swhx
           > connection.
           > I have tried Bytes.toString but when i send that
           over the Connection it
           > reports an error in the Unserializer.
           > Incidentally the other way around: from flash byte
           array to neko, it seems
           > to work fine.
           > So this works ( the byte array is auto converted to
           a string haxe/swhx
           > somewhere)
           > Bytes.ofString( my bytearray string over swhx
           connection);
           >
           > It seems a shame to have to loop the bytes to create
           an array to send back
           > .....
           > thanks Steve
           >
           > On 2 Jun 2011, at 16:53, laurence taylor wrote:
           >
           > I haven't used it but haxe.io.Bytes.ofString() might
           do it.
           >
           > On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           >
           > Hi,
           >
           > I have a swf that is wrapped in swhx.
           >
           > I also have another application that is sending
           binary data to a neko
           >
           > ServerLoop over a socket connection.(inside the swhx
           wrapper.)
           >
           > However I'm struggling to get the data thru to the
           swf using the standard
           >
           > Connection method i.e.
           cnx.someMethod.call([mybinarydata])
           >
           > If I send it it arrives as a series of characters
           but I'm not sure how they
           >
           > map to the original binary data.
           >
           > Is there a way to do this, or do I need to send an
           array of Ints ?
           >
           > Any help really appreciated as I'm pulling my hair
           out on this one!
           >
           > -thanks Steve
           >
           > Steve Anson
           >
           > Flash Developer
           >
           > Actionscript Solutions Ltd.
           >
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           >
           > haXe - an open source web programming language
           >
           > http://haxe.org <http://haxe.org/>
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >

           --
           haXe - an open source web programming language
           http://haxe.org <http://haxe.org/>


       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>




       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>





       --
       haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>


   --     haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>

   Steve Anson
   Flash Developer
   Actionscript Solutions Ltd.
   [hidden email] <[hidden email]>





   --
   haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>


--
haXe - an open source web programming language
http://haxe.org

Steve Anson
Flash Developer
Actionscript Solutions Ltd.
[hidden email] <[hidden email]>




Hi,
am just guessing that this might happen because the call to
buf.getData() on neko returns a NativeString ?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org


shouldn't it return a Bytes object?

If not how do I return that data back to flash via swhx.Connection?
 

At the moment I'm converting to an array of ints and sending that, this is actually sent as a comma deliminated string, which has to be split etc
seems very messy.

thanks Steve


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
Hi All,
thanks for your comments so far.

Movie A in my description is on the network and trying to pass data to the swhx wrapped flash Movie B on another machine. ( local network comms)
I think I am receiving the bytes in the ServerLoop just fine as I can trace them out.
I am a bit confused as to the difference between the ServerLoop and ThreadRemotingServer and what the purposes of each are.

I don't use haxe remoting in movie A as its a Flex air app, actually on an Android tablet, would having that as a haxe application solve the problem?

thanks Steve

On 4 Jun 2011, at 22:24, Cauê Waneck wrote:

Hey stephen, it seems that you are connecting through raw sockets, instead of using haxe remoting. Is that it? I've never used more than one flash client with swhx, but swhx has its own communication protocol. Have you tried that? It works pretty well.
Anyway, the Bytes you receive from processClientData aren't the actual bytes you sent. They are serialized. If you want to use sockets to communicate, have a look at ThreadRemotingServer and this example : http://haxe.org/doc/flash/chat  . Basically, you'll have to define a context with a function that will receive the bytes variable and send it to the other client.

Hope it helps
Cheers!
Caue



2011/6/4 Stephen Anson <[hidden email]>

On 4 Jun 2011, at 18:27, Axel Huizinga wrote:

Am 04.06.2011 18:15, schrieb Stephen Anson:
Hi,

thanks for giving this some attention!

// -- Movie A sends bytes using a binary Socket
// callWrapper is an object with targ:int id, func:String name and arg:* properties

callWrapper.targ = CommsConstants.TARG_BASE_SELF_PACED;
callWrapper.func = func;
callWrapper.arg = arg;
outSock.writeBytes( byteArrayConverter(callWrapper) ); // this creates a byte array and writes the object to it
outSock.flush();

// -- override from ServerLoop

override public function processClientData( d : ClientData, buf : haxe.io.Bytes, bufpos : Int, buflen : Int )
   {
ShareData.remoteComms.setRemoteManagerData(buf );
return buflen;
   }

// -- RemoteComms object sends to flash Movie B over swhx.Connection

public function setRemoteManagerData( buf:Bytes)
{
cnx.onRemoteManData.call([buf.getData()]); // when i send buf it ends up in flash as a string, when I send a buf.getData() an error occurs in UnSerializer
}

// -- movie B
public function onRemoteManData(data):void
{
// trace out data
}

//
I also notice that if i send a bytearray out over swhx.Connection it ends up in haxe as a String.
I am using swhx 1.2.0, haxe was recent download from google code.


thanks Steve

On 4 Jun 2011, at 14:36, Cauê Waneck wrote:

when you say you are sending the object as bytes, are you sending it as haxe.io.Bytes or as a ByteArray?

unserialization/serialization should run transparent to you in this case, so it really seems quite strange that you are receiving a string. If you are sending it as haxe.io.Bytes, I can't really think of how you are receving a string. Can  you post some of your code?

Cheers!
Caue

2011/6/4 Stephen Anson <[hidden email] <[hidden email]>>

   Just to clarify, I'm doing this:
   1. sending an object ( typed ) over a socket as bytes to a neko
   Server loop from flash movie 'A'
   2. sending those bytes on to flash movie 'B' over swhx Connection.

   In movie 'B', I then want to get the bytes back again in order to
   recreate my object using

   bytearray.readObject()

   Yes it does convert to a string, I then tried taking that string
   and doing this in flash:

   bytearray.writeUTFBytes(stringfromhaxe);

   however the bytes that I trace out are nothing like the original
   bytes that were sent

   does that explain it?

   Incidentally - 1. does work but I suspect there is a better way!!

   thanks Steve

   On 3 Jun 2011, at 13:54, Cauê Waneck wrote:

   if you send the bytes, it will convert as a string but when you
   unserialize it, it will convert it back to bytes again. So I
   don't get what seems to be the problem?

   2011/6/3 Stephen Anson <[hidden email] <[hidden email]>>

       Hi All,

       The options I see are:
       1. send and array of ints, to flash
       performance may be an issue as back in flash i have to
       convert the 'array int string' to an array, push that into a
       byte array in order to reconstruct my object

       2. Bypass swhx Connection and use a Binary socket
       shame as its already configured with a swhx Connection

       3. figure out how to convert the Bytes string back to a byte
       array
       no idea where to start


       Any ideas out there why this is so painful?

       thanks Steve

       Begin forwarded message:

       *From: *Stephen Anson <[hidden email]
       <[hidden email]>>
       *Date: *3 June 2011 09:01:41 GMT+01:00
       *To: *The haXe compiler list <[hidden email]
       <[hidden email]>>
       *Subject: **Re: [haXe] byte array passing to swhx*
       *Reply-To: *The haXe compiler list
       <[hidden email]
       <[hidden email]>>

       Hi,

       The problem is how to serialize the Bytes in order to get
       it back to the swf over a swhx Connection
       If I send the bytearray directly it can't serialize it I
       get this error:

       Called from c:\haxe/std/haxe/Serializer.hx line 393
       Called from c:\haxe/std/haxe/Serializer.hx line 208
       Called from swhx/Connection.hx line 67

       If I send the Bytes it converts to a string and sends that.
       If I then writeUTFBytes from the string back in flash
       bytearray and read the bytes they are nothing like the
       original bytes

       Any ideas?

       thanks Steve

       On 2 Jun 2011, at 22:44, Cauê Waneck wrote:

       ByteArray is the flash implementation of haxe.io.BytesData
       . You can convert back and forth ByteArray to Bytes like
       this: Bytes.fromData(myByteArray) and myBytesObject.getData()

       cheers!
       Caue

       2011/6/2 laurence taylor <[hidden email]
       <[hidden email]>>

           Have you checked haxe on google code, the mail
           archives and the changes.txt?

           On Thu, Jun 2, 2011 at 7:14 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           > Hi,
           > Also is it possible that a later build of haxe could
           fix this issue? I if is
           > one?
           > thanks Steve
           > On 2 Jun 2011, at 17:08, Stephen Anson wrote:
           >
           > Hi,
           > Bytes.ofString( some string) returns a Bytes object,
           - I already have  that
           > - i'm trying to get the Bytes object over  to flash
           over the swhx
           > connection.
           > I have tried Bytes.toString but when i send that
           over the Connection it
           > reports an error in the Unserializer.
           > Incidentally the other way around: from flash byte
           array to neko, it seems
           > to work fine.
           > So this works ( the byte array is auto converted to
           a string haxe/swhx
           > somewhere)
           > Bytes.ofString( my bytearray string over swhx
           connection);
           >
           > It seems a shame to have to loop the bytes to create
           an array to send back
           > .....
           > thanks Steve
           >
           > On 2 Jun 2011, at 16:53, laurence taylor wrote:
           >
           > I haven't used it but haxe.io.Bytes.ofString() might
           do it.
           >
           > On Thu, Jun 2, 2011 at 5:09 PM, Stephen Anson
           <[hidden email] <[hidden email]>> wrote:
           >
           > Hi,
           >
           > I have a swf that is wrapped in swhx.
           >
           > I also have another application that is sending
           binary data to a neko
           >
           > ServerLoop over a socket connection.(inside the swhx
           wrapper.)
           >
           > However I'm struggling to get the data thru to the
           swf using the standard
           >
           > Connection method i.e.
           cnx.someMethod.call([mybinarydata])
           >
           > If I send it it arrives as a series of characters
           but I'm not sure how they
           >
           > map to the original binary data.
           >
           > Is there a way to do this, or do I need to send an
           array of Ints ?
           >
           > Any help really appreciated as I'm pulling my hair
           out on this one!
           >
           > -thanks Steve
           >
           > Steve Anson
           >
           > Flash Developer
           >
           > Actionscript Solutions Ltd.
           >
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           >
           > haXe - an open source web programming language
           >
           > http://haxe.org <http://haxe.org/>
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >
           > Steve Anson
           > Flash Developer
           > Actionscript Solutions Ltd.
           > [hidden email] <[hidden email]>
           >
           >
           >
           >
           > --
           > haXe - an open source web programming language
           > http://haxe.org <http://haxe.org/>
           >

           --
           haXe - an open source web programming language
           http://haxe.org <http://haxe.org/>


       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>




       --         haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>

       Steve Anson
       Flash Developer
       Actionscript Solutions Ltd.
       [hidden email] <[hidden email]>





       --
       haXe - an open source web programming language
       http://haxe.org <http://haxe.org/>


   --     haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>

   Steve Anson
   Flash Developer
   Actionscript Solutions Ltd.
   [hidden email] <[hidden email]>





   --
   haXe - an open source web programming language
   http://haxe.org <http://haxe.org/>


--
haXe - an open source web programming language
http://haxe.org

Steve Anson
Flash Developer
Actionscript Solutions Ltd.
[hidden email] <[hidden email]>




Hi,
am just guessing that this might happen because the call to
buf.getData() on neko returns a NativeString ?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org


shouldn't it return a Bytes object?

If not how do I return that data back to flash via swhx.Connection?
 

At the moment I'm converting to an array of ints and sending that, this is actually sent as a comma deliminated string, which has to be split etc
seems very messy.

thanks Steve


--
haXe - an open source web programming language
http://haxe.org

--
haXe - an open source web programming language
http://haxe.org

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

go2ghana
Am 05.06.2011 00:44, schrieb Stephen Anson:

> Hi All,
> thanks for your comments so far.
>
> Movie A in my description is on the network and trying to pass data to
> the swhx wrapped flash Movie B on another machine. ( local network comms)
> I think I am receiving the bytes in the ServerLoop just fine as I can
> trace them out.
> I am a bit confused as to the difference between the ServerLoop and
> ThreadRemotingServer and what the purposes of each are.
>
>
How exactly do you send the data from A to B?


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Cauê W.
Ok, now i think get it ! : )

First of all, the only cross-target way to send bytes data on haXe remoting is with haxe.io.Bytes. When you send it out, it will serialize it to a string, and then unserialize it to call the specified remoting function. This all happens automatically if you're using haXe remoting (haxe.remoting.Connection, haxe.remoting.Context, etc) on both (ie neko and B) sides. Is that the case?
Are you sure that ServerLoop is receiving the info just fine?


2011/6/4 Axel Huizinga <[hidden email]>
Am 05.06.2011 00:44, schrieb Stephen Anson:

Hi All,
thanks for your comments so far.

Movie A in my description is on the network and trying to pass data to the swhx wrapped flash Movie B on another machine. ( local network comms)
I think I am receiving the bytes in the ServerLoop just fine as I can trace them out.
I am a bit confused as to the difference between the ServerLoop and ThreadRemotingServer and what the purposes of each are.


How exactly do you send the data from A to B?


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
In reply to this post by go2ghana
'A' sends data over binary socket to ServerLoop/neko, via local network, i.e they are not on same machine
ServerLoop/neko forwards data to 'B' over swhx connection

thanks Steve
On 5 Jun 2011, at 00:04, Axel Huizinga wrote:

Am 05.06.2011 00:44, schrieb Stephen Anson:
Hi All,
thanks for your comments so far.

Movie A in my description is on the network and trying to pass data to the swhx wrapped flash Movie B on another machine. ( local network comms)
I think I am receiving the bytes in the ServerLoop just fine as I can trace them out.
I am a bit confused as to the difference between the ServerLoop and ThreadRemotingServer and what the purposes of each are.


How exactly do you send the data from A to B?


--
haXe - an open source web programming language
http://haxe.org


Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: byte array passing to swhx

Stephen Anson
In reply to this post by Cauê W.
The issue I have is that I am using flex on remote machine compiling to an Android target, so that uses the Binary Socket.
ServerLoop is definitely receiving the correct bytes.
Currently as a work around I do this in neko part that receives the 'bytearray'

public function setRemoteManagerData( buf:Bytes)
{
var a:Array<Int> = [];
var i = 0;
var len = buf.length;
while (i < len) 
a[i] = buf.get(i); 
i++;
}
mySWHXConnection.onRemoteManData.call([a]);
}
that gets converted to a comma separated string, which i then split at the movie 'B' end and add the ints i.e. bytes to a ByteArray.
As that def works the bytes are 'good'

*** not going from movie B to neko (i.e. the reverse direction) the swhx.Connection happily converts the ByteArray to a string and in neko/haxe I can
use Bytes.ofString(myserialisedByteArray)



thanks Steve

On 5 Jun 2011, at 00:54, Cauê Waneck wrote:

 haxe.io.Bytes

Steve Anson 
Flash Developer
Actionscript Solutions Ltd.





--
haXe - an open source web programming language
http://haxe.org