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?
Offline
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.
Offline
Sounds interesting, im intruiged how this will turn out, but allas, i cant help.
Offline
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.
Offline
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)
Offline
What about having 2 different projects, the host and the client?
Offline
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
Offline
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.
Offline
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.
Offline
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
Offline
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!
Offline
But does it work? And if it doesn't, then i suggest leranng Python to act as a go between.
Offline
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
Offline
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
![]()
Well does it work with python?
Offline
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?
Offline
er, yes, that's why i'm not using Python... you suggested it in the first place
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.
Offline
sparks wrote:
er, yes, that's why i'm not using Python... you suggested it in the first place
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.
Offline
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.
Offline
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
good spot there though, thanks
Offline
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.
Offline