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
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
- Creating a ClientPacket
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.
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 must be registered to see links
. 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
You must be registered to see links
ServerPacket
You must be registered to see links
ClientPacket
You must be registered to see links
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.