looks cash, i may try my hand at it
As a fun project/learning experience I decided that I would write a server almost entirely in Python except use the JVM to run it through the Jython library (believe it or not, Jython runs much faster than standard Python because it benefits from the dynamic optimizations that the HotSpot JVM provides).
- Easy to develop with (you can literally learn Python in a few hours)
- No need to compile your code - no need for the JDK
- Extremely lightweight source code (the jython library jar is 1.8MB though)
- Very fast compared to standard Python
- Very simple source code.
- Easy "packaging", because of recursive script loading in the Engine, you can throw any scripts into any amount of sub-folders for organizational purposes and they will all be loaded the same. (also, no need for a "package" statement).
The server uses a very lightweight asynchronous networking library written in Java that I have made (called Helios). The jar has the source code in it, but there is no JavaDoc documentation. Feel free to use it in other projects. It has an Engine.jar (source files are in the jar) which contains the main Java code which loads all Python scripts into the interpreter (which then compiles them into bytecode) and calls the "bootstrap" method inside the interpreter.
However, because I am not nearly as good with Python as I am with Java, I have been unable to complete this source: I'm stuck on parsing incoming packets after login. So I'm asking you guys to do your best and take a shot at fixing it. If you fix it, major props to you and we can move on with developing this baby.
(mods: this stands apart from downloads/projects/help threads because it's unique compared to other servers and this main section in general will have a better response towards helping out. If it's in the projects section, nobody will look. If it's in the downloads section, nobody will use it as they're looking for complete sources. And if it's in the help section, well I wont get any useful help)
Download: [Only registered and activated users can see links. ]
I also thought it'd be kinda neat to just give this out as an example that we are not restricted to Java in this community.
looks cash, i may try my hand at it
Scripting languages ftl.
fast compared to standard python... um no
class OutLogger(object): def __init__(self): self.out = sys.stdout self.outlog = open("./logs/out.log", "a") def write(self, message): self.out.write(message) self.outlog.write(message) class ErrLogger(object): def __init__(self): self.err = sys.stderr self.errlog = open("./logs/err.log", "a") def write(self, message): self.err.write(message) self.errlog.write(message)
also you don't have to use getters/setters from jython
ps you guys are idiots, it's compiled into bytecode and not interpreted through the python interpreter
Well, it is most certainly different...
Edit - again
From that I get:Code:
def handle(self): session = self.session session.getInBuffer().flip() if session.getInBuffer().remaining() == 0: return inBuffer = session.getInRSBuffer() inBuffer.reset(session.getInBuffer().array(), session.getInBuffer().remaining()) if inBuffer.getOpcode() != -1: self.opcode = inBuffer.getOpcode() print "Opcode: ", self.opcode if RSBuffer.packetSizes[self.opcode] != -1: self.size = RSBuffer.packetSizes[self.opcode]; print "Size: ", self.size if self.size == 0: return; for i in range(0, self.size): print "Data: ", inBuffer.get() self.payload.add(inBuffer.get()) self.opcode = -1 self.size = -1 self.payload.clear() session.getInBuffer().clear()
Loading scripts... Loaded script: Main.py Loaded script: Protocol.py Loaded script: Server.py Loaded script: Session.py Loaded script: Logger.py Bootstrapping Jython RuneScape Emulator... Binding listener address - 127.0.0.1 : 43594 Server running! Accepting connection from: 127.0.0.1 Logged in user successfully. Logged in user successfully. Opcode: 174 Size: 0 Opcode: 220 Size: 0 Opcode: 138 Size: 0 Opcode: 207 Size: 0 Opcode: 105 Size: 0 Opcode: 66 Size: 0 Opcode: 39 Size: 2 Data: 255 Data: 61 Opcode: 127 Size: 0 Opcode: 83 Size: 0 Terminating connection from: 127.0.0.1
It prints 'Logged in user successfully.' at the end of the login method. Nothing special happens on the client.
That session includes logging in once from the client, waiting a few seconds - then closing the client.
Hope I could help.
|« Runescape "Secret spells"? | What do you Prefer? »|
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)