How does the emulator communicate with the swfs?

Synt4x

Member
Jan 13, 2016
77
59
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.
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
Code:
public function _SafeStr_2660(k:Function)
{
     super(k, CallForHelpPendingCallsMessageParser);
}

With outgoing packets you need to go into the super class
search for:
Code:
class CallForHelpPendingCallsMessageParser

and you should find the structure for the packet. int, string, bool ext.
 
Also another thing. I think you're going about searching for structures the wrong way.

Not sure how you went from:
MOTDNotificationMessageComposer

To:
CallForHelpPendingCallsMessageParser

Maybe you're trying to find the structures using the incoming method? Since I see you're searching for "new *class name*".
 

Synt4x

Member
Jan 13, 2016
77
59
With outgoing packets you need to go into the super class
search for:
Code:
class CallForHelpPendingCallsMessageParser

and you should find the structure for the packet. int, string, bool ext.
 
Also another thing. I think you're going about searching for structures the wrong way.

Not sure how you went from:
MOTDNotificationMessageComposer

To:
CallForHelpPendingCallsMessageParser

Maybe you're trying to find the structures using the incoming method? Since I see you're searching for "new *class name*".
Yeah, that's exactly how I was trying to find it. I couldn't find any tutorials about outgoing, so I had a fiddle with the tutorial that Sledmore wrote about incoming and see if I could try to work it out myself.

Code:
    public class CallForHelpPendingCallsMessageParser implements _SafeStr_2261
    {

        private var _SafeStr_8459:Array;

        public function CallForHelpPendingCallsMessageParser()
        {
            this._SafeStr_8459 = new Array();
            super();
        }

        public function get _SafeStr_8460():Array
        {
            return (this._SafeStr_8459);
        }

        public function get _SafeStr_8461():int
        {
            return (this._SafeStr_8459.length);
        }

        public function flush():Boolean
        {
            this._SafeStr_8459 = new Array();
            return (true);
        }

        public function parse(k:_SafeStr_2699):Boolean
        {
            var _local_3:int;
            var _local_4:Object;
            this._SafeStr_8459 = new Array();
            var _local_2:int = k._SafeStr_5287();
            while (_local_3 < _local_2)
            {
                _local_4 = new Object();
                _local_4.callId = k.readString();
                _local_4.timeStamp = k.readString();
                _local_4.message = k.readString();
                this._SafeStr_8459.push(_local_4);
                _local_3++;
            };
            return (true);
        }
    }

So, with finding that class now - where does it define that it needs an integer and a string? I presume that MOTDNotificationComposer is sending out the CallID and the message, but why not timestamp? Sorry for the mass questions, just trying to get a decent understanding of this. :) Thanks for the help.
 

Damien

Don't need glasses if you can C#
Feb 26, 2012
434
647
Yeah, that's exactly how I was trying to find it. I couldn't find any tutorials about outgoing, so I had a fiddle with the tutorial that Sledmore wrote about incoming and see if I could try to work it out myself.

Code:
    public class CallForHelpPendingCallsMessageParser implements _SafeStr_2261
    {

        private var _SafeStr_8459:Array;

        public function CallForHelpPendingCallsMessageParser()
        {
            this._SafeStr_8459 = new Array();
            super();
        }

        public function get _SafeStr_8460():Array
        {
            return (this._SafeStr_8459);
        }

        public function get _SafeStr_8461():int
        {
            return (this._SafeStr_8459.length);
        }

        public function flush():Boolean
        {
            this._SafeStr_8459 = new Array();
            return (true);
        }

        public function parse(k:_SafeStr_2699):Boolean
        {
            var _local_3:int;
            var _local_4:Object;
            this._SafeStr_8459 = new Array();
            var _local_2:int = k._SafeStr_5287();
            while (_local_3 < _local_2)
            {
                _local_4 = new Object();
                _local_4.callId = k.readString();
                _local_4.timeStamp = k.readString();
                _local_4.message = k.readString();
                this._SafeStr_8459.push(_local_4);
                _local_3++;
            };
            return (true);
        }
    }

So, with finding that class now - where does it define that it needs an integer and a string? I presume that MOTDNotificationComposer is sending out the CallID and the message, but why not timestamp? Sorry for the mass questions, just trying to get a decent understanding of this. :) Thanks for the help.

All the information you need is here:
Code:
public function parse(k:_SafeStr_2699):Boolean
        {
            var _local_3:int;
            var _local_4:Object;
            this._SafeStr_8459 = new Array();
            var _local_2:int = k._SafeStr_5287();
            while (_local_3 < _local_2)
            {
                _local_4 = new Object();
                _local_4.callId = k.readString();
                _local_4.timeStamp = k.readString();
                _local_4.message = k.readString();
                this._SafeStr_8459.push(_local_4);
                _local_3++;
            };
            return (true);
        }

But like I said you've gone about it the wrong way and this structure has nothing to do with MOTD. It's for the "CallForHelpPendingCallsMessageParser".
 

Synt4x

Member
Jan 13, 2016
77
59
All the information you need is here:
Code:
public function parse(k:_SafeStr_2699):Boolean
        {
            var _local_3:int;
            var _local_4:Object;
            this._SafeStr_8459 = new Array();
            var _local_2:int = k._SafeStr_5287();
            while (_local_3 < _local_2)
            {
                _local_4 = new Object();
                _local_4.callId = k.readString();
                _local_4.timeStamp = k.readString();
                _local_4.message = k.readString();
                this._SafeStr_8459.push(_local_4);
                _local_3++;
            };
            return (true);
        }

But like I said you've gone about it the wrong way and this structure has nothing to do with MOTD. It's for the "CallForHelpPendingCallsMessageParser".

Sorry, not sure what happened there when I was looking up that packet. It was just an error :)

This should be the right class though, correct?

Code:
    public class _SafeStr_3243 implements _SafeStr_2261
    {

        private var _SafeStr_10930:Array;


        public function flush():Boolean
        {
            this._SafeStr_10930 = new Array();
            return (true);
        }

        public function parse(k:_SafeStr_2699):Boolean
        {
            var _local_2:int = k._SafeStr_5287();
            var _local_3:int;
            while (_local_3 < _local_2)
            {
                this._SafeStr_10930.push(k.readString());
                _local_3++;
            };
            return (true);
        }

        public function get messages():Array
        {
            return (this._SafeStr_10930);
        }


    }

Is it pushing the Integer & String to public function parse(k:_SafeStr_2699):Boolean?
 

Users who are viewing this thread

Top