Exemplo n.º 1
0
        public Packet(JScript script, IPacket packet)
            : base(script.Engine)
        {
            var props = TypeDictionary.GetRecord(packet.GetType());

            DefineProperty("id", new PropertyDescriptor(
                               (int)packet.Id,
                               Jurassic.Library.PropertyAttributes.Enumerable | Jurassic.Library.PropertyAttributes.Sealed),
                           true
                           );

            foreach (var prop in props)
            {
                var info = prop.Property;

                string name = info.Name;
                name = name[0].ToString().ToLower() + name.Substring(1);

                this.DefineProperty(
                    name,
                    new PropertyDescriptor(
                        new GetProperty(script, packet, info),
                        new SetProperty(script, packet, info),
                        Jurassic.Library.PropertyAttributes.Enumerable | Jurassic.Library.PropertyAttributes.Sealed),
                    true);
            }
        }
Exemplo n.º 2
0
 private Scribble(JScript script, ObjectInstance proto, string source)
     : base(script.Engine, proto)
 {
     this.script = script;
     this.Source = source;
     this.PopulateFunctions();
 }
Exemplo n.º 3
0
 internal TimeSpanInstance(JScript script, TimeSpan span)
     : base(script.Engine, ((ClrFunction)script.Engine.Global["TimeSpan"]).InstancePrototype)
 {
     this.script = script;
     this.span   = span;
     this.PopulateFunctions();
 }
Exemplo n.º 4
0
 public Constructor(JScript script)
     : base(script.Engine.Function.InstancePrototype,
            "Hashlink",
            new Hashlink(script))
 {
     this.script = script;
 }
Exemplo n.º 5
0
        public static bool Create(string name)
        {
            name = name.ToLower();

            var script = JurassicPlugin.Scripts.Find((s) => s.Name.ToLower() == name);

            if (script != null)
            {
                Kill(name);
            }

            try {
                script = new JScript(name);

                JurassicPlugin.Self.Server.Users.ForEach((s) => script.Room.Users.Items.Add(new User(script, s)));
                JurassicPlugin.Scripts.Add(script);

                script.ResetCounters();

                return(true);
            }
            catch (JavaScriptException jex) {
                JurassicPlugin.Self.OnError(jex);
                Kill(name);
            }

            return(false);
        }
Exemplo n.º 6
0
        public static bool Load(string name)
        {
            name = name.ToLower();

            var script = JurassicPlugin.Scripts.Find((s) => s.Name.ToLower() == name);

            if (script != null)
            {
                Kill(name);
            }

            string path = Path.Combine(JurassicPlugin.Self.Directory, "Scripts", name, name + ".js");

            try {
                script = new JScript(name);

                JurassicPlugin.Self.Server.Users.ForEach((s) => script.Room.Users.Items.Add(new User(script, s)));
                JurassicPlugin.Scripts.Add(script);

                script.Eval(System.IO.File.ReadAllText(path));
                script.ResetCounters();

                return(true);
            }
            catch (JavaScriptException jex) {
                JurassicPlugin.Self.OnError(jex);
                Kill(name);
            }
            return(false);
        }
Exemplo n.º 7
0
        private User(JScript script)
            : base(script.Engine)
        {
            this.script = script;
            this.Client = new UserInvalid();

            this.PopulateFunctions();
        }
Exemplo n.º 8
0
        public ChannelHash(JScript script)
            : base(script, ((ClrFunction)script.Engine.Global["Hashlink"]).InstancePrototype)
        {
            this.script  = script;
            this.channel = new Channel();

            this.PopulateFunctions();
        }
Exemplo n.º 9
0
        internal HttpRequest(JScript script)
            : base(script.Engine)
        {
            this.script = script;

            this.Headers = new List(script);
            this.PopulateFunctions();
        }
Exemplo n.º 10
0
        public Channels(JScript script, IChannelList channels)
            : base(script.Engine)
        {
            this.channels = channels;
            this.monitor  = new Monitor(script, channels.Monitor);

            this.PopulateFunctions();
        }
Exemplo n.º 11
0
        public Banned(JScript script, IHistory history)
            : base(script, ((ClrFunction)script.Engine.Global["Collection"]).InstancePrototype)
        {
            this.script  = script;
            this.history = history;

            this.PopulateFunctions();
        }
Exemplo n.º 12
0
        private User(JScript script)
            : base(script.Engine)
        {
            this.script = script;
            this.user   = new UserProto();

            this.PopulateFunctions();
        }
Exemplo n.º 13
0
        public List(JScript script, object[] collection)
            : base(script, ((ClrFunction)script.Engine.Global["Collection"]).InstancePrototype)
        {
            this.items = new List <Object>();
            this.PopulateFunctions();

            collection.ForEach((s) => Add(s));
        }
Exemplo n.º 14
0
        public Config(JScript script, IServerConfig config)
            : base(script.Engine)
        {
            this.config = config;
            this.script = script;

            this.PopulateFunctions();
        }
Exemplo n.º 15
0
        private Collection(JScript script)
            : base(script)
        {
            this.script = script;
            this.items  = new List <Object>();

            this.PopulateFunctions();
        }
Exemplo n.º 16
0
        public Avatar(JScript script, ObjectInstance prototype, ArrayInstance smallbytes, ArrayInstance largebytes)
            : base(script.Engine, prototype)
        {
            this.PopulateFunctions();

            this.smallbytes = smallbytes;
            this.largebytes = largebytes;
        }
Exemplo n.º 17
0
        public Error(JScript script)
            : base(script.Engine)
        {
            this.script = script;

            this.PopulateFields();
            this.PopulateFunctions();
        }
Exemplo n.º 18
0
        public UserId(JScript script, Guid guid, IPAddress address)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["UserId"]).InstancePrototype)
        {
            this.guid    = guid;
            this.address = address;

            this.PopulateFunctions();
        }
Exemplo n.º 19
0
        public HttpRequest(JScript script, string url)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["HttpRequest"]).InstancePrototype)
        {
            this.Uri     = url;
            this.Headers = new List(script);

            this.PopulateFunctions();
        }
Exemplo n.º 20
0
        public UserId(JScript script, string guid, string address)
            : base(script.Engine)
        {
            this.Guid       = guid;
            this.ExternalIp = address;

            this.PopulateFunctions();
        }
Exemplo n.º 21
0
        public Monitor(JScript script, IMonitor monitor)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["Monitor"]).InstancePrototype)
        {
            this.script  = script;
            this.monitor = monitor;

            this.PopulateFunctions();
        }
Exemplo n.º 22
0
        public Collection(JScript script, ObjectInstance prototype)
            : base(script, prototype)
        {
            this.script = script;
            this.items  = new List <Object>();

            this.PopulateFunctions();
        }
Exemplo n.º 23
0
        public EncodingInstance(JScript script, System.Text.Encoding encoding)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["EncodingInstance"]).InstancePrototype)
        {
            this.script   = script;
            this.encoding = encoding;

            this.PopulateFunctions();
        }
Exemplo n.º 24
0
        public EncodingInstance(JScript script)
            : base(script.Engine)
        {
            this.script   = script;
            this.encoding = System.Text.Encoding.Default;

            this.PopulateFunctions();
        }
Exemplo n.º 25
0
        internal FloodRule(JScript script, int id, int count, int timeout)
            : base(script.Engine)
        {
            this.id    = id > 255 ? 255 : (id < 0) ? 0 : id;
            this.count = count;
            this.reset = timeout;

            this.PopulateFunctions();
        }
Exemplo n.º 26
0
        public Error(JScript script, JavaScriptException ex)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["Error"]).InstancePrototype)
        {
            this.error  = ex;
            this.script = script;

            this.PopulateFields();
            this.PopulateFunctions();
        }
Exemplo n.º 27
0
        public FloodRule(JScript script, IFloodRule rule)
            : base(script.Engine)
        {
            this.id    = rule.Id;
            this.count = rule.Count;
            this.reset = rule.ResetTimeout;

            this.PopulateFunctions();
        }
Exemplo n.º 28
0
        public User(JScript script, IClient client)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["User"]).InstancePrototype)
        {
            this.script  = script;
            this.user    = client;
            this.monitor = new Monitor(script, client.Monitor);

            this.PopulateFunctions();
        }
Exemplo n.º 29
0
        public Encoding(JScript script, bool init)
            : base(script.Engine)
        {
            this.script = script;
            this.PopulateFunctions();

            if (init)
            {
                this.Init();
            }
        }
Exemplo n.º 30
0
        public Avatar(JScript script, IAvatar avatar)
            : base(script.Engine, ((ClrFunction)script.Engine.Global["Avatar"]).InstancePrototype)
        {
            this.PopulateFunctions();

            if (avatar != null)
            {
                this.smallbytes = avatar.SmallBytes.ToJSArray(script.Engine);
                this.largebytes = avatar.LargeBytes.ToJSArray(script.Engine);
            }
        }