How does the emulator communicate with the swfs?
Hi everybody.
I've been a coder for the best part of 7 years now. PHP is my strongest language and thus I have good knowledge about Object-Orientated Programming. I know a little bit of C#, I picked the basics fairly fast as PHP was strongly influenced by C#.
Anyway, to the point - I want to further develop Plus Emulator and start coding in stuff that's already within the swfs that hasn't been developed yet. I believe this would be the best way to start. However, my biggest problem is I can't find any tutorials or posts explaining how the emulator sends and receives data to the swfs.
My current understanding:
I know that data is transferred over sockets and sent in packets. I believe that packets are used to send information to the swfs which can be used to trigger functions within classes. But how do I know what information to send to the swf? I have decompiled Habbo.swf and took a look at some of the functions that are linked to the packet headers. I.e. the MOTD notification:
ServerPacketHeader.cs
Code:
public const int MOTDNotificationMessageComposer = 705;
Habbo.swf
Code:
_SafeStr_5698[705] = _SafeStr_3230;
Code:
this.addMessageEvent(new _SafeStr_2660(this._SafeStr_10206));
Code:
public function _SafeStr_2660(k:Function)
{
super(k, CallForHelpPendingCallsMessageParser);
}
public function _SafeStr_5423():CallForHelpPendingCallsMessageParser
{
return ((_SafeStr_5424 as CallForHelpPendingCallsMessageParser));
}
What I don't understand however, is how MOTDNotificationComposer.cs communicates the values necessary to provide the text to the MOTD notification as I don't see where there is a string or integer parameter being required?
Code:
public MOTDNotificationComposer(string Message) : base(ServerPacketHeader.MOTDNotificationMessageComposer)
{
base.WriteInteger(1);
base.WriteString(Message);
}
Maybe I have the wrong understanding of how this all works, but I'd really like someone to be able to help me out with all of this, I want to be able to start developing emulators more.
Thank you, any light shed on this situation would be greatly appreciated.
Re: How does the emulator communicate with the swfs?
Quote:
What I don't understand however, is how MOTDNotificationComposer.cs communicates the values necessary to provide the text to the MOTD notification as I don't see where there is a string or integer parameter being required?
Lets take this packet for example (from my development project):
Code:
CreditsBalanceMessageComposer = 2588
Code:
class CreditsBalanceMessageComposer:
def __init__(self, currency_balance):
self.response = Response(outgoing.CreditsBalanceMessageComposer)
self.response.write_string(str(currency_balance))
You can see a string is required, if we look at the swfs, we get:
Code:
_SafeStr_7125[2588] = _SafeStr_2378;
Code:
public class _SafeStr_2378 extends _SafeStr_2258 implements _SafeStr_2255
{
public function _SafeStr_2378(k:Function)
{
super(k, _SafeStr_2331);
}
public function _SafeStr_5359():_SafeStr_2331
{
return ((this._SafeStr_5360 as _SafeStr_2331));
}
}
The above code tells us that the parsing class for this packet is _SafeStr_2331, which brings us to this class
Code:
package _-6Hf
{
import _-29g._SafeStr_2252;
import _-29g._SafeStr_2699;
public class _SafeStr_2331 implements _SafeStr_2252
{
private var _SafeStr_9185:int;
public function parse(k:_SafeStr_2699):Boolean
{
this._SafeStr_9185 = int(k.readString());
return (true);
}
public function flush():Boolean
{
return (true);
}
public function get balance():int
{
return (this._SafeStr_9185);
}
}
}//package _-6Hf
And you can see the parse method is where it reads the string :):
Code:
public function parse(k:_SafeStr_2699):Boolean
{
this._SafeStr_9185 = int(k.readString());
return (true);
}
Re: How does the emulator communicate with the swfs?
Quote:
Originally Posted by
Quackster
Lets take this packet for example (from my development project):
Code:
CreditsBalanceMessageComposer = 2588
Code:
class CreditsBalanceMessageComposer:
def __init__(self, currency_balance):
self.response = Response(outgoing.CreditsBalanceMessageComposer)
self.response.write_string(str(currency_balance))
You can see a string is required, if we look at the swfs, we get:
Code:
_SafeStr_7125[2588] = _SafeStr_2378;
Code:
public class _SafeStr_2378 extends _SafeStr_2258 implements _SafeStr_2255
{
public function _SafeStr_2378(k:Function)
{
super(k, _SafeStr_2331);
}
public function _SafeStr_5359():_SafeStr_2331
{
return ((this._SafeStr_5360 as _SafeStr_2331));
}
}
The above code tells us that the parsing class for this packet is
_SafeStr_2331, which brings us to this class
Code:
package _-6Hf
{
import _-29g._SafeStr_2252;
import _-29g._SafeStr_2699;
public class _SafeStr_2331 implements _SafeStr_2252
{
private var _SafeStr_9185:int;
public function parse(k:_SafeStr_2699):Boolean
{
this._SafeStr_9185 = int(k.readString());
return (true);
}
public function flush():Boolean
{
return (true);
}
public function get balance():int
{
return (this._SafeStr_9185);
}
}
}//package _-6Hf
And you can see the parse method is where it reads the string :):
Code:
public function parse(k:_SafeStr_2699):Boolean
{
this._SafeStr_9185 = int(k.readString());
return (true);
}
Thank you, that really cleared things up for me. One other thing that I'm confused about though, let's say that there's a feature within the hotel that has not yet been coded within the emulator - how would I go about finding the correct packets needed in order to start coding the logic to it? I presume I'd need a packetlogger?
Re: How does the emulator communicate with the swfs?
Quote:
Originally Posted by
Synt4xy
Thank you, that really cleared things up for me. One other thing that I'm confused about though, let's say that there's a feature within the hotel that has not yet been coded within the emulator - how would I go about finding the correct packets needed in order to start coding the logic to it? I presume I'd need a packetlogger?
Correct :D:, log the header that the client sent in the current/official Habbo, find the class in the SWF, and look for any similar code that's present in your version of the SWF, then back-track back to the header list :):
Re: How does the emulator communicate with the swfs?
Quote:
Originally Posted by
Quackster
Correct :D:, log the header that the client sent in the current/official Habbo, find the class in the SWF, and look for any similar code that's present in your version of the SWF, then back-track back to the header list :):
Perfect. Thank you very much :)