Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Plugin and Companion App SDK
Viewing all articles
Browse latest Browse all 54282

Send Multiple Java Messages at Once?

$
0
0

Hi

 

I am using the Photoshop Connection SDK to get my iPad app connected ot Photoshop.

 

While I have it working, its hard for me to solve my issue as I don't entirely understand the networking between the iPad and Photoshop. So here is my issue:

 

NSString *s1 = [NSStringstringWithUTF8String:"app.activeDocument.layers[0].name;"];

NSData *dataToSend = [s1 dataUsingEncoding:NSUTF8StringEncoding];

[selfsendJavaScriptMessage:dataToSend];

artLayerName_transaction = transaction_id -1;

 

There is a little snippet of code, to send a message asking for the name of layer at index 0. That works great. However, Lets say I try and send the same message straight after that but for index 1 as well.

 

Both messages are sent, but only one returns its string. The string is returned here:

- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)streamEvent;

 

If you see the example projects its just the same, each message with its own transaction id as well. The method goes througha bunch of decrypting and things to recieve that string and then reaches this:

 

NSString *string = [[NSStringalloc] initWithBytes:received_data length:received_length encoding:NSUTF8StringEncoding];

if (content != 1)

{

     if (transaction == artLayerName_transaction)

         {

              [selfprocessLayerName:string];

              needOutput = NO;

         }

}


It checks that its receiving the specific message so I can then take the result (string, my layer name) and do what I like with it. However when I try and send more than one message with the same transaction id I only get one of the two results. In the code above, string gives me both my layer names, but the if statement is only called once.

 

I have no clue why and I hope you can help. Is there a known way around sending several messages at once? I have tried getting an array back rather than several strings without luck as well.

 

Hope you can help, thanks.


Viewing all articles
Browse latest Browse all 54282

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>