コード例 #1
0
ファイル: Room.Handler.cs プロジェクト: hollow87/cb0t
        private void Eval_Features(TCPPacketReader packet)
        {
            String version = packet.ReadString(this.crypto);

            this.Credentials.Server = version;
            this.Panel.ServerText(StringTemplate.Get(STType.Messages, 17) + ": " + version);
            this.Panel.Userlist.UpdateServerVersion(version);
            this.should_check_for_current_topic_update = true;

            if (version.StartsWith("sb0t 5."))
            {
                version = version.Substring(version.IndexOf(" ") + 1).Split(' ')[0];
                String vnum_str = new String(version.Where(x => Char.IsNumber(x)).ToArray());

                uint vnum;

                if (!uint.TryParse(vnum_str, out vnum))
                {
                    vnum = 0;
                }

                this.new_sbot = (vnum >= 514);
            }
            else if (version.StartsWith("Ares 2.") || version.StartsWith("Ares_2."))
            {
                this.new_sbot = true; // maybe future Ares Server will support cb0t Custom Fonts?
            }
            ServerFeatures flag = (ServerFeatures)((byte)packet);

            this.CanVC = ((flag & ServerFeatures.SERVER_SUPPORTS_VC) == ServerFeatures.SERVER_SUPPORTS_VC);
            bool has_html        = ((flag & ServerFeatures.SERVER_SUPPORTS_HTML) == ServerFeatures.SERVER_SUPPORTS_HTML);
            bool has_scribble    = ((flag & ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES);
            bool has_pm_scribble = ((flag & ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES);

            this.CanOpusVC = ((flag & ServerFeatures.SERVER_SUPPORTS_OPUS_VC) == ServerFeatures.SERVER_SUPPORTS_OPUS_VC);
            this.Panel.CanVC(this.CanVC);
            this.Panel.CanScribbleAll(has_scribble);
            this.Panel.CanScribblePM(has_pm_scribble);
            this.Panel.InitScribbleButton();
            this.CanNP = true;

            if (has_html)
            {
                this.Panel.Userlist.AcquireServerIcon(this.EndPoint);
            }

            packet.SkipByte();
            this.Panel.ServerText(StringTemplate.Get(STType.Messages, 16) + ": " + (RoomLanguage)((byte)packet));
            uint cookie = packet;

            if (!String.IsNullOrEmpty(this.Credentials.Password))
            {
                this.sock.Send(TCPOutbound.SecureAdminLogin(this.Credentials.Password, cookie, this.Credentials.IP));
            }

            this.UpdatePersonalMessage();

            if (Avatar.Data != null)
            {
                this.sock.SendTrickle(TCPOutbound.Avatar());
            }

            if (Settings.GetReg <bool>("user_font_enabled", false))
            {
                this.sock.SendTrickle(TCPOutbound.Font(this.new_sbot, this.crypto));
            }

            if (Settings.GetReg <bool>("block_custom_names", false))
            {
                this.sock.SendTrickle(TCPOutbound.BlockCustomNames(true));
            }

            ScriptEvents.OnConnected(this);
        }