Exemple #1
0
        public bool R_IsEqual(object a)
        {
            if (!(a is Undefined))
            {
                if (a is JSRoom)
                {
                    JSRoom compare = (JSRoom)a;

                    if (compare.EndPoint != null)
                    {
                        if (this.EndPoint != null)
                        {
                            return(this.EndPoint.Equals(compare.EndPoint));
                        }
                    }
                }
            }

            return(false);
        }
Exemple #2
0
        public static void EventCycle(ulong time)
        {
            JSTimers.ServiceTimers(time);

            if (PendingTerminators.Pending)
            {
                IPEndPoint ep = null;

                while (PendingTerminators.TryDequeue(out ep))
                {
                    ClearUsers(ep);
                    ScriptEvents.OnRoomClosed(ep);

                    foreach (JSScript script in Scripts)
                    {
                        script.Rooms.RemoveAll(x => x.EndPoint.Equals(ep));
                    }
                }
            }

            if (PendingUIText.Pending)
            {
                JSOutboundTextItem item = null;

                while (PendingUIText.TryDequeue(out item))
                {
                    Room r = RoomPool.Rooms.Find(x => x.EndPoint.Equals(item.EndPoint));

                    if (r != null)
                    {
                        if (item.Type == JSOutboundTextItemType.Command)
                        {
                            String str = ScriptEvents.OnCommandSending(r, item.Text);

                            if (!String.IsNullOrEmpty(str))
                            {
                                r.SendCommand(str);
                            }
                        }
                        else if (item.Type == JSOutboundTextItemType.Public)
                        {
                            String str = ScriptEvents.OnTextSending(r, item.Text);

                            if (!String.IsNullOrEmpty(str))
                            {
                                r.SendText(str);
                            }
                        }
                        else if (item.Type == JSOutboundTextItemType.Emote)
                        {
                            String str = ScriptEvents.OnEmoteSending(r, item.Text);

                            if (!String.IsNullOrEmpty(str))
                            {
                                r.SendEmote(str);
                            }
                        }
                        else if (item.Type == JSOutboundTextItemType.Private)
                        {
                            String str = ScriptEvents.OnPmSending(r, item.Name, item.Text);

                            if (!String.IsNullOrEmpty(str))
                            {
                                r.SendPM(item.Name, str);
                            }
                        }
                        else if (item.Type == JSOutboundTextItemType.Link)
                        {
                            if (ScriptEvents.OnLinkClicked(r, item.Text))
                            {
                                try
                                {
                                    Process.Start(item.Text);
                                }
                                catch { }
                            }
                        }
                        else if (item.Type == JSOutboundTextItemType.ChatScreenCallback)
                        {
                            ScriptEvents.OnScreenCallback(r, item.Name, item.Text);
                        }
                    }
                }
            }

            if (PendingUIEvents.Pending)
            {
                JSUIEventItem item = null;

                while (PendingUIEvents.TryDequeue(out item))
                {
                    if (item.EventType == JSUIEventType.KeyPressed)
                    {
                        item.Element.KeyPressCallback((int)item.Arg);
                    }
                    else if (item.EventType == JSUIEventType.ValueChanged)
                    {
                        item.Element.ValueChangedCallback();
                    }
                    else if (item.EventType == JSUIEventType.Click)
                    {
                        item.Element.ClickCallback();
                    }
                    else if (item.EventType == JSUIEventType.Select)
                    {
                        item.Element.SelectCallback();
                    }
                    else if (item.EventType == JSUIEventType.ItemDoubleClick)
                    {
                        item.Element.ItemDoubleClickCallback();
                    }
                    else if (item.EventType == JSUIEventType.SelectedItemChanged)
                    {
                        item.Element.SelectedItemChangedCallback();
                    }
                    else if (item.EventType == JSUIEventType.UISelected)
                    {
                        ScriptEvents.OnUISelected((String)item.Arg);
                    }
                    else if (item.EventType == JSUIEventType.RoomOpened)
                    {
                        ScriptEvents.OnRoomOpened((IPEndPoint)item.Arg);
                    }
                    else if (item.EventType == JSUIEventType.RoomClosed)
                    {
                        ScriptEvents.OnRoomClosed((IPEndPoint)item.Arg);
                    }
                }
            }

            if (PendingPopupCallbacks.Pending)
            {
                JSUIPopupCallback item = null;

                while (PendingPopupCallbacks.TryDequeue(out item))
                {
                    JSScript script = Scripts.Find(x => x.ScriptName == item.Callback.Engine.ScriptName);

                    if (script != null)
                    {
                        Objects.JSRoom room = script.Rooms.Find(x => x.EndPoint.Equals(item.Room));

                        if (room != null)
                        {
                            try { item.Callback.Call(script.JS.Global, room); }
                            catch (Jurassic.JavaScriptException je)
                            {
                                ScriptManager.ErrorHandler(script.ScriptName, je.LineNumber, je.Message);
                            }
                        }