Jycraft / jycraft

Extend Minecraft servers with Python using Jython.
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

Handling multi-line input across connection types #20

Closed pauleveritt closed 8 years ago

pauleveritt commented 8 years ago

This plugin was originally aimed at interactive usage. Which means it expects a connection input/output approach that is different than an editor:

https://github.com/Jycraft/jycraft/blob/master/src-common/jycraft/plugin/servers/PySFListener.java#L125

Meaning, it tries to keep reading, across messages, until it thinks you are "finished". This works well for telnet and for the interactive interpreter in the browser. But it's a pain when we want to send over a single chunk of code to execute.

We have added JSON support to the web socket version. Should we refactor this to let the browser tell the server when it is sending a full "file"?

AngelMunoz commented 8 years ago

I think it would be like adding another case in the switch

switch (messageType) {
            case login:
            // code
                break;
            case interactive:
                //code
                break;
            case file:
                //code
                break;
            case logout:
               //code
                break;
            default:
                break;
        }

though if you think of a more elegant solution I would love to hear hahaha, since all of this stuff is new to me I'm still a bit lost on what to do or how to do ir properly. in these days i will do some rework on the implementation I made to fix some issues ben pointed and I will look into the file case you are mentioning

AngelMunoz commented 8 years ago

21 should cover this

AngelMunoz commented 8 years ago

22 did actually cover this, you can send a python script's path over the websocket to test a live execution or you can load them from a directory named python-plugins on the server's root directory, this is a working example of that.

execfiles