Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

WebCore Javascript client structure/encoding

Experienced Elementalist
Joined
Nov 11, 2015
Messages
238
Reaction score
89
Hi,

So for quite some time I've worked on a websockets integration for habbo. (Yes I will one day release the WebCore plugin for Arcturus).

For now though,
I'd like to share a part of the JS client, the core if you will. The protocol is quite like Habbo's.

At first my websockets client had my custom protocol which is String-based. A packet would look like:
"123|Keiz|Hi y'all" // all parameters were in the same string, devided by a character.
Even though my users were never close to understanding packets to begin with, yours might. I decided to create a Habbo-like protocol for my websockets. It is all written from scratch, although the byte-structure is Sulake's I suppose???

For now, it's just the encoding for anyone who likes to create their own websockets server, or likes to upgrade their own to a more safe protocol (imo). It includes
- PacketEncoding
- ServerPacket
- ClientPacket

So to be clear, I'm releasing the core of the WebCore JavaScript client, for you to either learn from, use it or review it. It's not the whole client nor server, only read on if you're interested.
Note
At the time I was learning JS and found it easy to use a library called . You can just copy the function contains and use them in your own classes if you understandably wish not to use JSFace.

but kiez idk what to do with this :c
Simply don't use it.

Sample use
Assuming you can set your own WS server/client up, just make sure the client is set up something like this

- handling a ServerPacket
Code:
ws.binaryType = "arraybuffer"; // Make sure your WebSocket.binaryType is set to "arraybuffer"
ws.onmessage = function(event) {    
    var bytes = new Uint8Array(event.data);    
    var serverPacket = new ServerPacket(bytes);
    switch(serverPacket.header)
    {
        case 123: // the same packet that used to be "123|Keiz|Hi y'all"
        {
            var user = serverPacket.popString();
            var message = serverPacket.popString();
            UI.showNotification(user, message); // example function
        }
    }
};

- Creating a ClientPacket
Example of creating a clientpacket:
Code:
var packet = new ClientPacket(1); // 1 being the header
packet.writeInteger(this._id);
packet.writeString(this._sso);

// \/ Send it to your WebSocket server like this \/
<<your WebSocket>>.send(packet.getBytes());

The files
PacketEncoding


ServerPacket


ClientPacket


What it's meant for
Educational purposes I guess. Even though the js classes are ready to use, don't blindly copy the samples. It also helps you understand the idea behind WebCore, a WebSocket-server-plugin for Arcturus which is some other time to be released.
 
Junior Spellweaver
Joined
Jan 28, 2013
Messages
157
Reaction score
104
I love where this is going. I've been looking into a way to implement WebSockets into HabboAPI. Since my project is Node I can simply use socket.io, but getting that client communication is key. Looking forward to seeing the Arcturus plugin get released.

Great work
 
Joined
Aug 24, 2012
Messages
603
Reaction score
300
Ay poop, I need a second to let the classiness waft over me ?.?
Didn't SteveWinfield release something like this? I know they're different and yours seems way better..
 
git bisect -m
Loyal Member
Joined
Sep 2, 2011
Messages
2,171
Reaction score
916
Yeah, 'CLEAN' code. Really nice. Like Bill said, socket.io could do the trick. Bot socket.io works for both pure JavaScript and NodeJS, as far I know.

But developing something from scratch specific for Habbo it's really nice. But I need to say that this would only work if the emulator has not RC4 encryption and also RSA disabled.

Anyways, you're basically encoding the packets in the HabboEncoding way.

Liked it. :)
 
Back
Top