Arinerron / ScratchAPI

A library written in Java for accessing scratch.mit.edu via your Java application...
Other
6 stars 4 forks source link

Setting Cloud Data doesn't work #2

Closed Arinerron closed 8 years ago

Arinerron commented 8 years ago

The file that contains the cloud data libraries it here > https://github.com/Arinerron/ScratchAPI/blob/master/src/edu/mit/scratch/ScratchCloudSession.java

jacobduba commented 8 years ago

I'll see what I can do here...

Arinerron commented 8 years ago

@MooShoe Thanks a lot! I can't figure out what I did wrong...

jacobduba commented 8 years ago

btw what ide / plugins are you using? I'm not to familiar with java with git.

Arinerron commented 8 years ago

@MooShoe I use Eclipse Mars and add the apache-httpclient libraries in. (I just imported everything in from Eclipse to Git.)

jacobduba commented 8 years ago

I didn't even have to import anything. :) Every library you added is all ready referenced.

Arinerron commented 8 years ago

:D

jacobduba commented 8 years ago

Is it just me or does it take FOREVER to load files and run the program?

Arinerron commented 8 years ago

Sorry, but just you... When I click it, it runs right away... BTW, are you still having issues with logging in? If so, do you know what line number the error is coming from? :)

ghost commented 8 years ago

I'll test this on Eclipse

jacobduba commented 8 years ago

It was coming from the line that threw the error... (Success!=0 then throw log in error) It was because you can only log into the same account once per computer.

About my programs speed, it takes about 5 seconds to log in. (Is that normal) It can't even finish the program, I suspect it's egit's fault.

Arinerron commented 8 years ago

Do you mind pasting the error (and of course you can snip out sensitive info)?

jacobduba commented 8 years ago

I don't have the error, I could try to pull it up again.

jacobduba commented 8 years ago

I removed eGit, it works nicely.

jacobduba commented 8 years ago

Hey - did you forget to add Scratch.cloud before the variable? The variable needs to have the symbol for it to work. I'm not on my computer with eclipse right now so I can't test it, I will though.

Arinerron commented 8 years ago

@MooShoe I don't think so; What I did was

  1. set variable to Scratch.CLOUD + " data";
  2. get variable's value
  3. set variable's value to 10
  4. get variable's value

And they both printed the same value and didn't throw an exception, so I know the variable name isn't the problem...

jacobduba commented 8 years ago

Wut? The variables name is Scratch.cloud + name, the value is just a number. Do you still have your code?

Arinerron commented 8 years ago

@MooShoe

This code is in a function that throws Exception by the way, so no try/catch is needed.

ScratchSession session = Scratch.createSession("arinerron", "<password snipped>");
ScratchCloudSession cloudSession = session.getCloudSession(103969700);

String variable = Scratch.CLOUD + " test";

System.out.println("before: " + cloudSession.get(variable)); // get
cloudSession.set(variable, "10"); // set
System.out.println("after: " + cloudSession.get(variable)); // get

No Exceptions or anything, but 'before' and 'after' are the same value.

Arinerron commented 8 years ago

Update: I just found out that it doesn't send a handshake to the server when it connects. This may be the problem, I'm writing a new function for it now!

Arinerron commented 8 years ago

Also, I just realized a have a while true loop in the constructor. I wonder why that is there :P

ghost commented 8 years ago

wat rly

Arinerron commented 8 years ago

Finally got it to work. The problem was partially the wrong encoding (ISO_8859_1, it should be UTF-8), but mostly that the index for the substring method had one too many, I don't know how I didn't find that out before. :)