This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-03-02 13:40:55

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Differentiate between mesh clients.

Ok, this might be a little tough to swallow as it's tricky to explain...

Basically, Mesh, as you know, can connect two projects, host and client. However, given the same IP address, two clients can be created to one server.

I was hoping to create a text hosting server.

the problem: The host cannot differentiate between the two mash projects under the conditions I require:

1) each client project has to have exactly the same scripting so that it can be distributed and used without editing, but has a variable called myid that is set to a random value on first use so that an ID is generated unique to that client project.

2) The host must be able to recieve data from different client projects (who of course have all the same variable names) without any new scripts being added for every new ID and differentiate between them using their ID variable.

The little problems:
1) first I thought that each client project could set the data it wants to send to the host as a varible called "packet" using (join (myID) (data)) and announcing the request to the Host using a broadcast "requestdata".

the idea with this was that the packet variable would be updated from whichever client had last used it and the broadcast would tell the host to seperate the packet variable to the ID and the data. this way the data would be sent with the correct address.

Alas! for some reason "packet" is only updated by the client who connected last. this means that the previous client can change the packet variable as much as it likes and the host is unaware of a change.
_______________________________________________________________________________

Well, that's it... can anyone come up with an ingenious way of getting the host to tell identical projects with different ID's apart?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#2 2010-03-02 13:45:01

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Differentiate between mesh clients.

Actually, I think that it is possible to connect different scratch projects with mesh, but unless the variables are the same, there won't be much happening.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#3 2010-03-02 13:56:59

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

Sounds interesting, im intruiged how this will turn out, but allas, i cant help.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#4 2010-03-02 14:43:13

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

juststickman wrote:

Actually, I think that it is possible to connect different scratch projects with mesh, but unless the variables are the same, there won't be much happening.

Juststickman, I am aware that connecting projects together with mesh is possible, I have connected three together, one host, two clients in order to test my hypothesis. It's not going too well right now. what is ideally needed is for there there to be some kind of reporter block that reports the last broadcast.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2010-03-02 14:52:04

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Differentiate between mesh clients.

I have thought about this problem a lot. The main problem I can come up with is that if the message is broadcasted by a different client while the server is still handling the first client's request, the first client's script that sent the 'broadcast and wait' will stop executing and be stuck at the that block. Now that I think of it, there is a completely different way to do this. I will make two projects and post them, then provide a link here.

Oh, sorry, that won't work. I was thinking of using lists to process multiple requests, but mesh cannot sense lists. I am still going to post the two projects, though, with a slightly altered method.

I just discovered a very interesting problem: the 'broadcast and wait' block does not wait for other projects in the mesh to handle the message. For example, if a server request is sent as a 'broadcast and wait' message, the sender will proceed to retrieve the data before it is ready.

Last edited by nXIII (2010-03-02 15:25:18)


nXIII

Offline

 

#6 2010-03-02 15:11:44

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

What about having 2 different projects, the host and the client?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#7 2010-03-02 15:25:41

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Differentiate between mesh clients.

markyparky56 wrote:

What about having 2 different projects, the host and the client?

We want more than one client; that is the problem.


nXIII

Offline

 

#8 2010-03-02 15:27:23

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

nXIII wrote:

markyparky56 wrote:

What about having 2 different projects, the host and the client?

We want more than one client; that is the problem.

Ah, let me direct you to the thread which is discussing this kinda of thing. http://scratch.mit.edu/forums/viewtopic.php?id=31540


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#9 2010-03-02 16:06:54

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

well I read through the entire forum thread you linked me to and know all sorts of things about servers and Hamachi and stuff now, but I am none the wiser to this problem.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#10 2010-03-02 16:11:22

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

The problem is that you can't distrbute client software where lots of changes need to be made to the script - it's just not feasable, people wouldn't get it or make one little mistake. even if only one special variable had to be created and the variable only appeared in one place, the Host project would still have to have new scripts added in order to process the new variable.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#11 2010-03-02 16:13:59

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

oh yes, to solve the problem of two clients requesting one of the host scripts at once, such as the "requestdata" script mentioned above, I had a variable called "requestdata" that set to busy when it got a request and set to free when the request was dealt with. that way other clients can wait until requestdata is free before sending something.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#12 2010-03-02 16:26:15

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Differentiate between mesh clients.

OK, I finished my example. I think this is what you want. Interestingly, it doesn't use IDs because it doesn't need to, but as many clients as you want can send requests. BE WARNED: running this server at too high a speed is disastrous, because the server finishes the request so fast that the client gets hung up waiting for the server to start processing it.

Links:

Server
Client


nXIII

Offline

 

#13 2010-03-02 16:27:37

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Differentiate between mesh clients.

sparks wrote:

oh yes, to solve the problem of two clients requesting one of the host scripts at once, such as the "requestdata" script mentioned above, I had a variable called "requestdata" that set to busy when it got a request and set to free when the request was dealt with. that way other clients can wait until requestdata is free before sending something.

LOL that's what I did!


nXIII

Offline

 

#14 2010-03-02 16:37:28

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

nXIII wrote:

LOL that's what I did!

great minds think alike!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#15 2010-03-03 11:02:44

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

But does it work? And if it doesn't, then i suggest leranng Python to act as a go between.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#16 2010-03-03 12:16:00

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

markyparky56 wrote:

But does it work? And if it doesn't, then i suggest leranng Python to act as a go between.

apparently it works, just not on my computer. Also, I already know Python, integrated mesh is just easier. less things to open up  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#17 2010-03-03 12:17:57

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

sparks wrote:

markyparky56 wrote:

But does it work? And if it doesn't, then i suggest leranng Python to act as a go between.

apparently it works, just not on my computer. Also, I already know Python, integrated mesh is just easier. less things to open up  smile

Well does it work with python?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#18 2010-03-03 12:39:05

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

Well does it work with python?

of course! Snyff is written in Python and works very well.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#19 2010-03-03 13:33:07

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

sparks wrote:

Well does it work with python?

of course! Snyff is written in Python and works very well.

But Snyff is for only a client and host, aren't you tring to work out how to do it for more than one client? or have i been living on another world?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#20 2010-03-03 13:51:48

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

er, yes, that's why i'm not using Python... you suggested it in the first place  tongue  I think the problem has been solved now, it was only a problem on my computer so i'll see what happens with my Brother's laptop. the next thing I'm working on is keeping all the sent information private - eg, the ID given to the project needs to be sent with the message so that the host can tell where it came from, but seeing as all other projects can see global variables, they might be able to see a person's ID, change their own and then impersonate that person.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#21 2010-03-03 14:05:15

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

sparks wrote:

er, yes, that's why i'm not using Python... you suggested it in the first place  tongue  I think the problem has been solved now, it was only a problem on my computer so i'll see what happens with my Brother's laptop. the next thing I'm working on is keeping all the sent information private - eg, the ID given to the project needs to be sent with the message so that the host can tell where it came from, but seeing as all other projects can see global variables, they might be able to see a person's ID, change their own and then impersonate that person.

Use a list or variable of course. involving broadcasts probably.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#22 2010-03-03 14:45:07

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

Use a list or variable of course. involving broadcasts probably.

erm, but all clients can read all the other clients global variables that are used to communicate with the host.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#23 2010-03-03 14:47:43

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Differentiate between mesh clients.

sparks wrote:

Use a list or variable of course. involving broadcasts probably.

erm, but all clients can read all the other clients global variables that are used to communicate with the host.

I think you can read non global variables, you just use the sensor block.

http://img709.imageshack.us/img709/4789/privatevariable.png


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#24 2010-03-03 16:21:13

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

I think you can read non global variables, you just use the sensor block.

http://img709.imageshack.us/img709/4789 … riable.png

oh... bum. It seems you can't keep it private at all... well, you can use list items rather than variables, but that means rewriting my whole script  hmm  good spot there though, thanks  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#25 2010-03-03 16:26:39

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Differentiate between mesh clients.

a good test of something like this is where you get someone else to try and hack it - eg, get the name or password of someone else to see how secure the information is, before setting it up, also hacking it yourself! if there's no way for YOU to do it, there probably isn't a way, seeing as you scripted it. I'm going to have a look at how some web data is encrypted and copy that.

i'm thinking if each project upon startup generates a random order in which to muddle up the characters it sends, then as long as the host has a copy of that random order to decode it at the other end, the data will be muddled up to any other viewer. the flaw with that is that the random order needs to be sent at some point, and someone can see it then and make a note.

I don't want to use substitution as it requires lots of scripting and really slows down data sending.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

Board footer