Reputation: 431
Working on a tool, in which i want to send a file to another peer, which i connect to. IF you know how to send byte array to another user using peer to peer, please let me know. I'm using net group for grouping and net stream to connect, and using peer ID to communicate with other user.
Upvotes: 0
Views: 425
Reputation: 5497
the following is from my app, sharedboard.net, modified a bit:
public function sendBAMessage(text: String): void {
var message: Object = new Object();
message.ba = myByteArray; //you may want to copy the bytarray
message.time = new Date().time;
message.type = "byteArray";
netGroup.post(message);
}
public function recieveMessage(o:Object):void{
if(o.type == "byteArray"){
var byteArrayRecieved : ByteArray = o.ba;
}
of course, you don't need to add time and type to your message, but it helps future expansion.
if you need the recieve handling as well:
public function netStatus(e: NetStatusEvent): void {
switch (e.info.code) {
.....
case "NetGroup.Posting.Notify":
recieveMessage(e.info.message)
break;
.....
Upvotes: 1