public void Handle(ByteMessage message)
        {
            // If the user 1 flag is set then this is a session management message.
            // Do not pass to the higher layers but rather process locally.
            if ((message.Data[0] & 0x40) == 0x40)
            {
                var type = FLMsgType.GetUInt32(message.Data, ref message.Position);
                // On receipt of a trans user data session info we send back a dummy
                // entry that's just sufficient to let the client's dplay implementation
                // to recognise us.
                switch (type)
                {
                case 0xC1:
                    if (_sessionState != FLServer.Player.Session.State.CONNECTING)
                    {
                        return;
                    }
                    _sessionState = FLServer.Player.Session.State.CONNECTING_SESSINFO;
                    SendTUDSessionInfo();
                    break;

                case 0xC3:
                    if (_sessionState != FLServer.Player.Session.State.CONNECTING_SESSINFO)
                    {
                        return;
                    }
                    _sessionState = FLServer.Player.Session.State.CONNECTED;
                    var p = Context.System.Guardian.GetSingleChild("server").Ask <LocalActorRef>("NewPlayer");
                    p.Wait(10);
                    _playerRef = p.Result;

                    // FLPACKET_SERVER_CONNECTRESPONSE
                    byte[] omsg = { 0x01, 0x02 };
                    var    num  = _playerRef.Path.Name.Split('/')[1];
                    var    pid  = uint.Parse(num);
                    FLMsgType.AddUInt32(ref omsg, pid);
                    Handle(omsg);
                    Handle(new SendNews());
                    //Sender.Tell(omsg);
                    //OnPlayerConnected(sess);
                    break;
                }
            }
            // If this is a complete message then pass up.
            else if ((message.Data[0] & 0x30) == 0x30)
            {
                if ((message.Data.Length - message.Position) <= 0)
                {
                    return;
                }

                byte[] msg = FLMsgType.GetArray(message.Data, ref message.Position, message.Data.Length - message.Position);
                _playerRef.Tell(msg);
            }
            // Otherwise we don't support this. Flag the error.
            else
            {
                _log.Warn("{0} unsupported message: {1}", Self.Path, message.Data);
            }
        }
        public void Handle(ConnectRequest message)
        {
            if (_sessionState == FLServer.Player.Session.State.CONNECTED)
            {
                return;
            }

            var selection = Context.System.ActorSelection("user/server/globals");
            var glob      = selection.ResolveOne(TimeSpan.FromSeconds(1));

            glob.Wait(750);
            _globals = glob.Result;

            if (_dPlayID != 0 && message.DPlayID != _dPlayID)
            {
                //throw new Exception("DPlay ID changed!");
                _log.Warn("{0} DPlay ID changed!", Context.Self.Path);
                return;
                //TODO: do something clever
            }
            _sessionState = FLServer.Player.Session.State.CONNECTING;
            _dPlayID      = message.DPlayID;

            byte[] pkt = { 0x88, 0x02 };
            FLMsgType.AddUInt8(ref pkt, message.MsgID++);
            FLMsgType.AddUInt8(ref pkt, message.RspID);
            FLMsgType.AddUInt32(ref pkt, 0x10004);
            FLMsgType.AddUInt32(ref pkt, message.DPlayID);
            FLMsgType.AddUInt32(ref pkt, (uint)Stopwatch.GetTimestamp());

            //sess.BytesTx += pkt.Length;
            Context.Parent.Tell(new Session.ConnectingMessage());
            Context.Sender.Tell(pkt, Context.Self);
        }