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

#1 2009-03-29 23:55:27

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Snyff: Simplified Scratch Networking

For those of you who would like to play around with linking two Scratch projects over a network, but don't want to mess around with Python, this Adobe AIR program might be of interest:

http://scratchconnections.wik.is/User:Chalkmarrow/Snyff

http://scratchconnections.wik.is/@api/deki/files/112/=image005.png

Basically, when two computers are hooked up, broadcasts from one computer are also seen by the other, and global variables from one computer show up as sensor values in the other. There are also some special features to make things easier to design multi-player projects.

It is based on archmage's idea of using Flash as the go-between, and is written in Adobe Flex (MXML + Actionscript 3). It runs as an executable file on any platform, and is simple to use.

The source code is included on the site (or you can just right click the application).

Once you have two computers hooked up, Snyff operates in accordance with only four simple rules:

1. Every global variable (not list or local variable) you change or create in one computer appears as a sensor value (blue blocks) in the other computer.
2. Every broadcast in one computer gets sent as a broadcast to the other computer, except:
3. Every broadcast that starts with "@" is _not_ sent to the other computer, and
4. Every broadcast that starts with ">" is changed to start with "<" and _then_ sent to the other computer.

That's it.

Last edited by chalkmarrow (2009-04-03 16:14:13)

Offline

 

#2 2009-03-30 04:56:22

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

This looks amazing!  Oh, the possibilities...

The documentation looks great, very complete.  There are a couple of odd coding tags that are hanging out in it (when viewed with IE7 anyway).

Great job!


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-03-31 10:01:38

abeair
Scratcher
Registered: 2008-07-19
Posts: 100+

Re: Snyff: Simplified Scratch Networking

Cool! My AIR needs an update, though. It wouldn't install, saying "Adobe AIR needs to be updated. Installing the update failed."


http://dragcave.net/image/NPtA.gif
http://www.danasoft.com/sig/ObamaLovesMacs.jpg

Offline

 

#4 2009-03-31 11:17:00

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

abeair wrote:

Cool! My AIR needs an update, though. It wouldn't install, saying "Adobe AIR needs to be updated. Installing the update failed."

Yeah, you need AIR 1.5, which I confirmed works with Snyff on Ubuntu 8.10, WinXP, and MacOSX.

Offline

 

#5 2009-03-31 20:37:30

abeair
Scratcher
Registered: 2008-07-19
Posts: 100+

Re: Snyff: Simplified Scratch Networking

chalkmarrow wrote:

abeair wrote:

Cool! My AIR needs an update, though. It wouldn't install, saying "Adobe AIR needs to be updated. Installing the update failed."

Yeah, you need AIR 1.5, which I confirmed works with Snyff on Ubuntu 8.10, WinXP, and MacOSX.

Thanks.


http://dragcave.net/image/NPtA.gif
http://www.danasoft.com/sig/ObamaLovesMacs.jpg

Offline

 

#6 2009-04-01 08:38:12

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

I *love* this, chalkmarrow! Especially the brilliant idea to use special characters to control message addressees, and the "snyffsez" lolcat-ish system messages. You're a genius!


Jens Mönig

Offline

 

#7 2009-04-01 13:06:02

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

Jens wrote:

I *love* this, chalkmarrow! Especially the brilliant idea to use special characters to control message addressees, and the "snyffsez" lolcat-ish system messages. You're a genius!

Thanks! It's actually a lot of fun. I was playing a simple two-person Doodle game with someone in another room and we couldn't stop laughing.

Re the special characters,  I really tried to make the program as simple and vanilla as possible, without any messy additions, but it became apparent early on that there are certain difficulties inherent in building projects where every broadcast is seen everywhere.

To make it easier, I had to address two broadcast-namespace issues. The first was that you need to have a project-specific namespace for your own computer (thus the "@" prefix), and the second was that you needed a project-specific namespace for your friend's computer (thus ">"). The second one gives you a way to break the "symmetry" of broadcasting.

The other major problem is that you can't create sensor-variables during design time (V1.5, anyone?). You would have to go through the trouble of connecting to another computer just to create the sensor variables to stick in your scripts. That's why I made the design helper part.

Offline

 

#8 2009-04-01 16:46:13

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

I agree that routing messages to specific targets looks like the way to go. I've experimented with an expanded broadcasting system myself, but only within a single Scratch project, in which each object can either broadcast messages to all, so a specific other object, or - as subroutines - to itself. But I didn't manage to apply that to networked Scratch sessions. Usually I'm not a big fan of reserved special chars in messages, however, I love your idea because of its simplicity and because it works :-) - and also because it's way cool!


Jens Mönig

Offline

 

#9 2009-04-01 17:04:47

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

Jens wrote:

I agree that routing messages to specific targets looks like the way to go. I've experimented with an expanded broadcasting system myself, but only within a single Scratch project, in which each object can either broadcast messages to all, so a specific other object, or - as subroutines - to itself. But I didn't manage to apply that to networked Scratch sessions. Usually I'm not a big fan of reserved special chars in messages, however, I love your idea because of its simplicity and because it works :-) - and also because it's way cool!

Nice. I like the pinpointed broadcast concept.

And yeah, I was pretty hesitant to use the special characters also. At first, I used special commands, but that got a bit cumbersome and easy to mess up. As I may have mentioned, I designed it with my 9-year-old watching me and telling me what made sense to him. The idea that putting a @ or > as a first character changes the way a broadcast bounces around is very intuitive, but when I used command syntax like "snyff selfbroadcast hello", not so much. I think this has to do with kids' comfort with the idea of prefixes in language.

Last edited by chalkmarrow (2009-04-01 17:05:42)

Offline

 

#10 2009-04-01 17:13:58

demosthenes
Retired Community Moderator
Registered: 2008-02-19
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

My question is, do you have to trust the other user enough to make a connection to them  and 2 what if I don't want to give out my IP?


I've taken a long hiatus, but I still visit sometimes. Give me some time to answer any messages you post on my projects!

Offline

 

#11 2009-04-02 09:27:49

abeair
Scratcher
Registered: 2008-07-19
Posts: 100+

Re: Snyff: Simplified Scratch Networking

demosthenes wrote:

My question is, do you have to trust the other user enough to make a connection to them  and 2 what if I don't want to give out my IP?

Yeah. Me too.


http://dragcave.net/image/NPtA.gif
http://www.danasoft.com/sig/ObamaLovesMacs.jpg

Offline

 

#12 2009-04-02 10:13:59

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

Well the host computer doesn't need to give their IP but the remote computer does.

I wouldn't worry about IP sharing, I know a few games that do this sort of thing.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#13 2009-04-02 10:29:08

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

archmage wrote:

Well the host computer doesn't need to give their IP but the remote computer does.

I wouldn't worry about IP sharing, I know a few games that do this sort of thing.

Yeah. You're trading your IP address with hundreds of computers each day, actually.

I should warn you that it is difficult to set up a socket connection between two home computers via the Internet, because there are typically two or more firewalls in the way, and configuring them is a real pain. I made the program primarily to play games across a home network.

Also, remember, your IP address as it appears within your network is different from how it appears from outside the network (because of your cable modem, router, gateway, whatever else).

So, for example, when I go to whatsmyip.org on this computer, it tells me that my IP address is:
68.108.193.54
but when I ask my computer (via a Windows console), it says my IP address is:
192.168.0.8

Offline

 

#14 2009-04-02 10:45:31

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

So if you are behind a router this is how you find your IP on a PC running windows.

1. Click start
2.Click all programs
3. Click accessories
4. Click Command Prompt
5. Type ipconfig into the prompt

Now this you give you a bunch of info about your connection. Just look for something that says IP address and the number beside it is your IP address.
smile


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#15 2009-04-02 10:48:57

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

archmage wrote:

So if you are behind a router this is how you find your IP on a PC running windows.

1. Click start
2.Click all programs
3. Click accessories
4. Click Command Prompt
5. Type ipconfig into the prompt

Now this you give you a bunch of info about your connection. Just look for something that says IP address and the number beside it is your IP address.
smile

Exactly. Plus on a mac you type "netstat", and on linux you type "ifconfig".

Offline

 

#16 2009-04-02 11:20:12

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

A good guide to the sort of things you need to do to allow socket connections through a firewall is in Agnes Chang's guide to her networked pong game:

http://scratchconnections.wik.is/Projects/Two-player_Network_Pong

Offline

 

#17 2009-04-02 11:58:58

adityasm9
Scratcher
Registered: 2008-03-12
Posts: 100+

Re: Snyff: Simplified Scratch Networking

*bows down to chalkmarrow*

Offline

 

#18 2009-04-02 23:20:23

KingOfGames
Scratcher
Registered: 2009-03-28
Posts: 100+

Re: Snyff: Simplified Scratch Networking

archmage wrote:

So if you are behind a router this is how you find your IP on a PC running windows.

1. Click start
2.Click all programs
3. Click accessories
4. Click Command Prompt
5. Type ipconfig into the prompt

Now this you give you a bunch of info about your connection. Just look for something that says IP address and the number beside it is your IP address.
smile

Or you can:

Click start
then click run
type in cmd
press enter
type in ipconfig
look for the ip. there ya go

Offline

 

#19 2009-04-03 04:32:09

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

KingOfGames wrote:

Or you can:

Click start
then click run
type in cmd
press enter
type in ipconfig
look for the ip. there ya go

Vista doesn't have a Run button...you have to find the Command Prompt application  sad


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#20 2009-04-03 04:39:15

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

What is the feasiblity of using this for projects involving more than two computers?  I notice that there is an effort afoot to try and make something larger over here

http://scratch.mit.edu/forums/viewtopic.php?pid=105328#p105328

The last time I looked into this, I really didn't see how the sockets could be made to work with more than one computer at a time so it seemed like you would have to continually be opening and closing sockets.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#21 2009-04-03 12:10:01

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

Paddle2See wrote:

What is the feasiblity of using this for projects involving more than two computers?  I notice that there is an effort afoot to try and make something larger over here

http://scratch.mit.edu/forums/viewtopic.php?pid=105328#p105328

Thanks. I hadn't seen that link.

The last time I looked into this, I really didn't see how the sockets could be made to work with more than one computer at a time so it seemed like you would have to continually be opening and closing sockets.

I am planning on trying something on a small scale in my home network connecting four or five computers. What you do is, each computer has its own copy of Snyff, with one connection made to Scratch at localhost, and the other connection made to a base socket server running on a base computer (which I haven't even scratched the surface of). This is a long term project, though, as the optimal logic for communication between computers is still not clear to me (though I made Snyff as general as possible so that I wouldn't have to worry about it early on). I suspect the actual real programmers out there will probably figure this out way before I do  smile

Offline

 

#22 2009-04-03 12:32:10

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

That is excataly what I was thinking could be done as well.

I just wonder how many connections it takes to crash the base sever.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#23 2009-04-03 12:55:08

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

I am assuming we are dealing with TCP sockets, where I believe the server creates one socket for each client, but the sockets share the same local socket address. Like I said, though, I haven't really looked into it yet.

Offline

 

#24 2009-04-03 14:53:28

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Snyff: Simplified Scratch Networking

You know, there's also an experimental "hidden" feature in the public Scratch Source Code which you can unlock without having to get much into Smalltalk-programming at all, and which will let you connect any number of Scratch sessions via TCP to do your MMO's without any middleware involved: http://scratch.mit.edu/forums/viewtopic.php?pid=96799#p96799


Jens Mönig

Offline

 

#25 2009-04-03 15:19:11

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Snyff: Simplified Scratch Networking

Jens wrote:

You know, there's also an experimental "hidden" feature in the public Scratch Source Code which you can unlock without having to get much into Smalltalk-programming at all, and which will let you connect any number of Scratch sessions via TCP to do your MMO's without any middleware involved: http://scratch.mit.edu/forums/viewtopic.php?pid=96799#p96799

That looks like a cool option, which I haven't looked into yet. So is the result the same? Every broadcast/global variable gets shared? The only problem I would forsee is that superglobal broadcasts, in practice, can be confusing. On the other hand, it sure simplifies the task of making a server. I'll have to try that out.

Offline

 

Board footer