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

#26 2011-12-22 16:10:26

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Still nothing?


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#27 2011-12-22 16:11:05

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

blob8108 wrote:

Have you considered using a framework like Twisted for this sort of thing? I imagine it could make things easier (or sometimes just unnecessarily complicated  tongue )

I oh so very much dislike Twisted. It gives me too many problems.

MathWhiz: You haven't sent any data from what I can see.

Last edited by Magnie (2011-12-22 16:11:44)

Offline

 

#28 2011-12-22 16:12:41

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Is the server using exactly the same code?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#29 2011-12-22 16:14:24

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

blob8108 wrote:

Is the server using exactly the same code?

What do you mean?

Okay, I got something "morning. How are you?" but it wasn't sent as a variable. ( 0000<chat Morning. How are you? )

Offline

 

#30 2011-12-22 16:16:10

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

blob8108 wrote:

Is the server using exactly the same code?

What do you mean?

Okay, I got something "morning. How are you?" but it wasn't sent as a variable. ( 0000<chat Morning. How are you? )

That wasn't me...


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#31 2011-12-22 16:17:15

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

blob8108 wrote:

Is the server using exactly the same code?

What do you mean?

Sorry — I mean, what's listening on 174.27.218.81:6112? More Python code?

Magnie wrote:

Okay, I got something "morning. How are you?" but it wasn't sent as a variable. ( 0000<chat Morning. How are you? )

Sorry, that was me telneting to the port to see if it worked...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#32 2011-12-22 16:18:00

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

Magnie wrote:

blob8108 wrote:

Is the server using exactly the same code?

What do you mean?

Okay, I got something "morning. How are you?" but it wasn't sent as a variable. ( 0000<chat Morning. How are you? )

That wasn't me...

Hmm, oh well.

Edit:

blob8108: Then the telnet worked.  tongue  All that is listening on 6112 is Python.

Last edited by Magnie (2011-12-22 16:21:00)

Offline

 

#33 2011-12-22 16:21:27

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

All that is listening on 6112 is Python.

Is it the same mirror code running at your end, too?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#34 2011-12-22 16:23:11

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

blob8108 wrote:

Magnie wrote:

All that is listening on 6112 is Python.

Is it the same mirror code running at your end, too?

No. All it is, is the server. But I am running a mirror on my own computer to send and receive messages to and from the server.

Offline

 

#35 2011-12-22 16:24:06

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

blob8108 wrote:

Is it the same mirror code running at your end, too?

No. All it is, is the server. But I am running a mirror on my own computer to send and receive messages to and from the server.

And Scratch is acting as the server, yes?  smile

Last edited by blob8108 (2011-12-22 16:24:19)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#36 2011-12-22 16:25:30

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

blob8108 wrote:

Magnie wrote:

blob8108 wrote:

Is it the same mirror code running at your end, too?

No. All it is, is the server. But I am running a mirror on my own computer to send and receive messages to and from the server.

And Scratch is acting as the server, yes?  smile

No, it's just Python. Using Scratch as a server is the worst idea ever.

Offline

 

#37 2011-12-22 16:30:40

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Chat.PY and Other Features

Magnie wrote:

blob8108 wrote:

Magnie wrote:


No. All it is, is the server. But I am running a mirror on my own computer to send and receive messages to and from the server.

And Scratch is acting as the server, yes?  smile

No, it's just Python. Using Scratch as a server is the worst idea ever.

So I'd've thought -- I understand now; it just echoes things to each client.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#38 2011-12-22 16:32:14

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

blob8108 wrote:

Magnie wrote:

blob8108 wrote:


And Scratch is acting as the server, yes?  smile

No, it's just Python. Using Scratch as a server is the worst idea ever.

So I'd've thought -- I understand now; it just echoes things to each client.  smile

Well. In a way I guess: http://scratch.mit.edu/forums/viewtopic.php?id=83823 <- that is the un-updated code for the server.

Offline

 

#39 2011-12-22 16:44:12

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Did you see the message, "You'd better see this. D:"?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#40 2011-12-22 16:45:18

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

Did you see the message, "You'd better see this. D:"?

Nope, it didn't show up.

Offline

 

#41 2011-12-22 16:49:30

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

yikes  I received something! Now?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#42 2011-12-22 16:51:32

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

yikes  I received something! Now?

Yeah, I'm getting stuff now.  tongue

Make sure your mirror can receive and send at the same time.

Offline

 

#43 2011-12-22 17:05:16

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Your server is not sending a broadcast telling Scratch to update the log. Is it supposed to?


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#44 2011-12-22 17:07:27

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

Your server is not sending a broadcast telling Scratch to update the log. Is it supposed to?

It is. I'm getting your messages:

Code:

Overlap wait time...
Following 'chat' variable.
Overlap wait time...
Magnie has joined!
Magnie: Hmm
Magnie: You still on?
MathWizz: Hmm?
Magnie: I think it works
MathWizz: Ello?
Magnie: Hiya
Magnie: Are you getting my messages?
MathWizz: Ello??
MathWizz: Hmm....
Magnie: Hi
Magnie: Are you getting my messages....?
MathWizz: This is Math. :D
MathWizz: ...
Magnie: ...
MathWizz: Testing with quotes. >:)
MathWizz: "Hi!"
Magnie: Hiya
Magnie: Hello?
MathWizz: Hmm... That worked... ""\674\][\]623[45\]756\3%$|^%$\63%$\^5\4*|}67'8\"

I don't think you are receiving my messages, what is your mirror code?

Last edited by Magnie (2011-12-22 17:08:08)

Offline

 

#45 2011-12-22 17:09:19

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Code:

import java.net.*;
import java.io.*;
import java.util.*;

public class Mirror
{
    public static void main(String[] args)
    {
        try
        {
            Socket scratch = new Socket("127.0.0.1", 42001);
            System.out.println("Connected to Scratch!");
            Socket server = new Socket("scratch.playfultest.tk", 6112);
            System.out.println("Connected to Magnie's server!");
            
            BufferedReader scratchin = new BufferedReader(new InputStreamReader(scratch.getInputStream()));
            BufferedWriter scratchout = new BufferedWriter(new OutputStreamWriter(scratch.getOutputStream()));
            
            BufferedReader serverin = new BufferedReader(new InputStreamReader(server.getInputStream()));
            BufferedWriter serverout = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
            
            int i;
            boolean serverNeedsFlush = false;
            boolean scratchNeedsFlush = false;
            while (true)
            {
                if (scratchin.ready())
                {
                    i = scratchin.read();
                    serverout.write(i);
                    serverNeedsFlush = true;
                }
                else if(serverNeedsFlush)
                {
                    serverout.flush();
                    serverNeedsFlush = false;
                }
                if (serverin.ready())
                {
                    i = serverin.read();
                    System.out.print((char)i);
                    scratchout.write(i);
                    scratchNeedsFlush = true;
                }
                else if(scratchNeedsFlush)
                {
                    scratchout.flush();
                    scratchNeedsFlush = false;
                }
            }
        }
        catch (IOException e)
        {
            System.out.println("Error!");
            e.printStackTrace();
            System.exit(0);
        }
    }
}

EDIT: Yeah, it's Java.

Last edited by MathWizz (2011-12-22 17:09:42)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#46 2011-12-22 17:11:47

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

Code:

import java.net.*;
import java.io.*;
import java.util.*;

public class Mirror
{
    public static void main(String[] args)
    {
        try
        {
            Socket scratch = new Socket("127.0.0.1", 42001);
            System.out.println("Connected to Scratch!");
            Socket server = new Socket("scratch.playfultest.tk", 6112);
            System.out.println("Connected to Magnie's server!");
            
            BufferedReader scratchin = new BufferedReader(new InputStreamReader(scratch.getInputStream()));
            BufferedWriter scratchout = new BufferedWriter(new OutputStreamWriter(scratch.getOutputStream()));
            
            BufferedReader serverin = new BufferedReader(new InputStreamReader(server.getInputStream()));
            BufferedWriter serverout = new BufferedWriter(new OutputStreamWriter(server.getOutputStream()));
            
            int i;
            boolean serverNeedsFlush = false;
            boolean scratchNeedsFlush = false;
            while (true)
            {
                if (scratchin.ready())
                {
                    i = scratchin.read();
                    serverout.write(i);
                    serverNeedsFlush = true;
                }
                else if(serverNeedsFlush)
                {
                    serverout.flush();
                    serverNeedsFlush = false;
                }
                if (serverin.ready())
                {
                    i = serverin.read();
                    System.out.print((char)i);
                    scratchout.write(i);
                    scratchNeedsFlush = true;
                }
                else if(scratchNeedsFlush)
                {
                    scratchout.flush();
                    scratchNeedsFlush = false;
                }
            }
        }
        catch (IOException e)
        {
            System.out.println("Error!");
            e.printStackTrace();
            System.exit(0);
        }
    }
}

EDIT: Yeah, it's Java.

Hmm, I can't tell if it can send and receive at the same time...

What what I can see is this:
1. Scratch Sends Message
2. Server Sends a Message Back
3. Scratch Sends Message
4. etc

it needs to do both at once:
1. Scratch sends message server sends message
2. etc

Offline

 

#47 2011-12-22 17:13:04

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Chat.PY and Other Features

Hmm... I could try setting up threads to do it at the same time. I don't think that will change anything though.


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#48 2011-12-22 17:14:34

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

MathWizz wrote:

Hmm... I could try setting up threads to do it at the same time. I don't think that will change anything though.

Hmm... Try the Python client for a bit.

I'm getting your messages, so I can't see why you aren't getting mine...

Last edited by Magnie (2011-12-22 17:17:47)

Offline

 

#49 2011-12-22 17:50:11

Solarbuddy
Scratcher
Registered: 2009-04-14
Posts: 500+

Re: Chat.PY and Other Features

This is what my scripts look after I'm done:
http://troll.ws/mRoIWD
Is that right?


http://bit.ly/Vn3zid
                  View my latest project

Offline

 

#50 2011-12-22 17:53:44

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Chat.PY and Other Features

Solarbuddy wrote:

This is what my scripts look after I'm done:
http://troll.ws/mRoIWD
Is that right?

No.

It's When I Receive "^follow_update"

Last edited by Magnie (2011-12-22 17:54:19)

Offline

 

Board footer