• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Send Multiple Java Messages at Once?

Community Beginner ,
Feb 18, 2013 Feb 18, 2013

Copy link to clipboard

Copied

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 = [NSString stringWithUTF8String:"app.activeDocument.layers[0].name;"];

NSData *dataToSend = [s1 dataUsingEncoding:NSUTF8StringEncoding];

[self sendJavaScriptMessage: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 = [[NSString alloc] initWithBytes:received_data length:received_length encoding:NSUTF8StringEncoding];

if (content != 1)

{

     if (transaction == artLayerName_transaction)

         {

              [self processLayerName: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.

TOPICS
SDK

Views

523

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Feb 19, 2013 Feb 19, 2013

Copy link to clipboard

Copied

That's because you're keeping one global transaction ID, so only one of them can be responded to.

To handle more than one message at a time, you'll have to change the example code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 19, 2013 Feb 19, 2013

Copy link to clipboard

Copied

LATEST

Guessed as much, my main issue is then not really understanding all the decryption and data transfer code.

While it would be massively appreciated I can't expect anyone to talk me through it (although it would likely be of huge help to may developers as I assume many using the SDK are new to the idea of networkinng).

However, if you have any tips or can point me to any docs or resources that might help me through this I'd really be thankful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines