Ejemplo n.º 1
0
        private async void UpdateTheme(ThemeDefinition Def, string TabID)
        {
            try
            {
                this.themeId = Def.Id;

                if (this.Step <= 0)
                {
                    this.Step = 1;
                }

                this.Updated = DateTime.Now;
                await Database.Update(this);

                Gateway.HttpServer.ETagSalt = this.Updated.Ticks.ToString();

                ClientEvents.PushEvent(new string[] { TabID }, "ThemeOk", JSON.Encode(new KeyValuePair <string, object>[]
                {
                    new KeyValuePair <string, object>("themeId", Def.Id),
                    new KeyValuePair <string, object>("cssUrl", Def.CSSX),
                }, false), true, "User");
            }
            catch (Exception ex)
            {
                Log.Critical(ex);
            }
        }
Ejemplo n.º 2
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tTextBox", writer);

            objectWriter.Start();

            objectWriter.AppendObject("val", this.Value);
            objectWriter.AppendObject("step", this.IncrementStep);
            objectWriter.AppendObject("minValue", this.MinValue);
            objectWriter.AppendObject("maxValue", this.MaxValue);
            objectWriter.Append("digits", this.DecimalDigits);
            objectWriter.Append("separator", this.DecimalSeparator);
            objectWriter.AppendNullableString("groupSeparator", this.NumberGroupSeparator);
            objectWriter.Append("groupSize", this.NumberGroupSize);
            objectWriter.Append("negative", this.NegativePatternIndex);
            objectWriter.Append("text", this.EmptyMessage);
            objectWriter.Append("type", "numeric");

            var inputAttributes = new Dictionary <string, string>();

            this.InputHtmlAttributes.Each(x => inputAttributes.Add(x.Key, x.Value.ToString()));
            objectWriter.AppendObject("inputAttributes", inputAttributes);

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets TabIDs based in restrictions in input arguments.
        /// </summary>
        /// <param name="Arguments">Tab restrictions.</param>
        /// <param name="Node">Script node getting the tabs.</param>
        /// <returns>Tab IDs</returns>
        public static string[] GetTabs(IElement[] Arguments, ScriptNode Node)
        {
            switch (Arguments.Length)
            {
            case 0:
                return(ClientEvents.GetTabIDs());

            case 1:
                object Obj = Arguments[0].AssociatedObjectValue;
                if (Obj is Array A)
                {
                    if (!(A is string[] Pages))
                    {
                        Pages = (string[])Expression.ConvertTo(A, typeof(string[]), Node);
                    }

                    return(ClientEvents.GetTabIDsForLocations(Pages));
                }
                else if (Obj is IUser User)
                {
                    return(ClientEvents.GetTabIDsForUser(User));
                }
                else
                {
                    return(ClientEvents.GetTabIDsForLocation(Obj?.ToString()));
                }

            case 2:
                return(ClientEvents.GetTabIDsForLocation(Arguments[0].AssociatedObjectValue?.ToString(),
                                                         GetQueryFilter(Arguments[1], Node)));

            default:
                return(new string[0]);
            }
        }
Ejemplo n.º 4
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tDateTimePicker", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Append("format", this.Format);
            objectWriter.Append("minValue", this.MinValue);
            objectWriter.Append("maxValue", this.MaxValue);
            objectWriter.Append("startTimeValue", this.StartTime);
            objectWriter.Append("endTimeValue", this.EndTime);
            objectWriter.Append("interval", this.Interval);
            objectWriter.Append("selectedValue", this.Value);
            objectWriter.Append("enabled", this.Enabled, true);

            if (DropDownHtmlAttributes.Any())
            {
                objectWriter.Append("dropDownAttr", DropDownHtmlAttributes.ToAttributeString());
            }

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Evaluates the function.
        /// </summary>
        /// <param name="Arguments">Function arguments.</param>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Function result.</returns>
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            int c = Arguments.Length;
            int d = c - 2;

            IElement[] A = new IElement[d];

            Array.Copy(Arguments, 0, A, 0, d);
            string[] TabIDs = GetTabIDs.GetTabs(A, this);

            if (TabIDs.Length > 0)
            {
                object Data = Arguments[c - 1].AssociatedObjectValue;

                if (Data is string s)
                {
                    ClientEvents.PushEvent(TabIDs, Arguments[c - 2].AssociatedObjectValue?.ToString(), s, false);
                }
                else
                {
                    ClientEvents.PushEvent(TabIDs, Arguments[c - 2].AssociatedObjectValue?.ToString(), JSON.Encode(Data, false), true);
                }
            }

            return(new ObjectVector(TabIDs));
        }
Ejemplo n.º 6
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tTextBox", writer);

            objectWriter.Start();

            objectWriter.AppendObject("val", Value);
            objectWriter.Append("step", IncrementStep);
            objectWriter.AppendObject("minValue", MinValue);
            objectWriter.AppendObject("maxValue", MaxValue);
            objectWriter.Append("symbol", PercentSymbol);
            objectWriter.Append("digits", DecimalDigits);
            objectWriter.Append("separator", DecimalSeparator);
            objectWriter.AppendNullableString("groupSeparator", NumberGroupSeparator);
            objectWriter.Append("groupSize", NumberGroupSize);
            objectWriter.Append("positive", PositivePatternIndex);
            objectWriter.Append("negative", NegativePatternIndex);
            objectWriter.Append("text", EmptyMessage);
            objectWriter.Append("type", "percent");

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 7
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tDatePicker", writer);

            objectWriter.Start();

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Append("format", this.Format);
            objectWriter.Append("todayFormat", TodayFormat);
            objectWriter.AppendDateOnly("minValue", this.MinValue);
            objectWriter.AppendDateOnly("maxValue", this.MaxValue);
            objectWriter.AppendDateOnly("selectedValue", this.Value);
            objectWriter.Append("enabled", this.Enabled, true);
            objectWriter.Append("openOnFocus", this.OpenOnFocus, false);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 8
0
        private static MySqlConnection CreateConnection()
        {
            var db = new MySqlConnection(ConString);

            db.Open();
            ClientEvents.Log(new LogMessage(LogSeverity.Info, "Database", "Connection Open"));
            return(db);
        }
Ejemplo n.º 9
0
 private void Ctrl_updateEvent(object sender, ClientEvents e)
 {
     if (e.UserEvent == UserEvent.newArticle)
     {
         List <string> listArticle = getAllArticlesforAuthor();
         listBox_myArticles.Invoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { listBox_myArticles, listArticle });
     }
 }
Ejemplo n.º 10
0
 private void Ctrl_updateEvent(object sender, ClientEvents e)
 {
     if (e.UserEvent == UserEvent.newConference)
     {
         int idConf = int.Parse(e.Data.ToString());
         List <Conference> listConf = ctrl.getAllPlannedConferences();
         parentForm.dataGridView2.Invoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { parentForm.dataGridView2, listConf });
     }
 }
Ejemplo n.º 11
0
 private void Ctrl_updateEvent(object sender, ClientEvents e)
 {
     if (e.UserEvent == UserEvent.newUser)
     {
         int idConf = int.Parse(e.Data.ToString());
         List <Participant> listPart = ctrl.getAllParticipantsByConference(idConf);
         dataGridView1.BeginInvoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { dataGridView1, listPart });
     }
 }
Ejemplo n.º 12
0
        public void sendMessage(string message)
        {
            BroadcastRequest request = new BroadcastRequest()
            {
                message = message, userName = Properties.Settings.Default.Config.userName
            };

            ClientEvents.invokeMessageSent(request);
        }
Ejemplo n.º 13
0
        public static void Setup(API api)
        {
            DxDrawLib.API = api;
            API.consoleOutput("[DxDrawLib] Setting up...");

            ClientEvents.Init();

            API.consoleOutput("[DxDrawLib] Successfully set up!");
        }
Ejemplo n.º 14
0
        private Task Evaluate(Expression Script, Variables Variables, string Id)
        {
            object Result = this.Evaluate(Script, Variables);

            StringBuilder Html = new StringBuilder();

            InlineScript.GenerateHTML(Result, Html, true, Variables);

            return(ClientEvents.ReportAsynchronousResult(Id, "text/html; charset=utf-8", Encoding.UTF8.GetBytes(Html.ToString())));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Evaluates the function.
        /// </summary>
        /// <param name="Arguments">Function arguments.</param>
        /// <param name="Variables">Variables collection.</param>
        /// <returns>Function result.</returns>
        public override IElement Evaluate(IElement[] Arguments, Variables Variables)
        {
            string[] TabIDs = GetTabIDs.GetTabs(Arguments, this);

            if (TabIDs.Length > 0)
            {
                ClientEvents.PushEvent(TabIDs, "Reload", "");
            }

            return(new ObjectVector(TabIDs));
        }
Ejemplo n.º 16
0
 private string[] GetTabIDs()
 {
     if (Gateway.Configuring)
     {
         return(ClientEvents.GetTabIDs());
     }
     else
     {
         return(ClientEvents.GetTabIDsForLocation("/Settings/Roster.md"));
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Removes a file from all pages viewing backup files
        /// </summary>
        /// <param name="FileName">Name of file</param>
        public static void UpdateClientsFileDeleted(string FileName)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("{\"fileName\":\"");
            sb.Append(CommonTypes.JsonStringEncode(FileName));
            sb.Append("\"}");

            string[] TabIDs = ClientEvents.GetTabIDsForLocation("/Settings/Backup.md");

            Task _ = ClientEvents.PushEvent(TabIDs, "FileDeleted", sb.ToString(), true, "User");
        }
Ejemplo n.º 18
0
    private void ProcessPackets()
    {
        if (UnityClient.PacketsToProccess.Count > 0)
        {
            var packetsToProcess = UnityClient.PacketsToProccess.ToArray();

            // Not an asset, just process the packet
            var packet = UnityClient.PacketsToProccess[0];
            ClientEvents.Call(packet);
            UnityClient.PacketsToProccess.RemoveAt(0);
        }
    }
Ejemplo n.º 19
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tComboBox", writer);

            objectWriter.Start();

            objectWriter.Append("autoFill", AutoFill, true);
            objectWriter.Append("ignoreCase", IgnoreCase, true);
            objectWriter.Append("highlightFirst", HighlightFirstMatch, true);
            objectWriter.Append("placeholder", this.Placeholder);
            objectWriter.Append("cascadeTo", this.CascadeTo);

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);

            DataBinding.Ajax.SerializeTo <AutoCompleteBindingSettings>("ajax", objectWriter, this);
            DataBinding.WebService.SerializeTo <AutoCompleteBindingSettings>("ws", objectWriter, this);

            if (Filtering.Enabled)
            {
                objectWriter.Append("filter", (int)Filtering.FilterMode);
                objectWriter.Append("minChars", Filtering.MinimumChars, 0);
            }

            if (hasItems)
            {
                objectWriter.AppendCollection("data", Items);
            }
            else
            {
                objectWriter.Append("selectedValue", this.GetValue <string>(Value));
            }

            objectWriter.Append("index", SelectedIndex, -1);

            if (DropDownHtmlAttributes.Any())
            {
                objectWriter.Append("dropDownAttr", DropDownHtmlAttributes.ToAttributeString());
            }

            objectWriter.Append("encoded", this.Encoded, true);
            objectWriter.Append("enabled", this.Enabled, true);
            objectWriter.Append("openOnFocus", this.OpenOnFocus, false);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 20
0
        private void RosterItemRemoved(string BareJid)
        {
            string[] TabIDs = this.GetTabIDs();
            if (TabIDs.Length > 0)
            {
                string Json = JSON.Encode(new KeyValuePair <string, object>[]
                {
                    new KeyValuePair <string, object>("bareJid", BareJid)
                }, false);

                Task _ = ClientEvents.PushEvent(TabIDs, "RemoveRosterItem", Json, true, "User");
            }
        }
Ejemplo n.º 21
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var objectWriter = ClientSideObjectWriterFactory.Create(Id, "tEditor", writer);

            objectWriter.Start();

            ClientEvents.SerializeTo(objectWriter);

            DefaultToolGroup.Tools.OfType <IEditorListTool>().Each(tool =>
            {
                if (!tool.Items.SequenceEqual(EditorDefaultOptions.Get(tool.Identifier)))
                {
                    objectWriter.AppendCollection(tool.Identifier, tool.Items);
                }
            });

            var urlBuilder = new EditorUrlBuilder(urlGenerator, ViewContext);

            FileBrowserSettings.SerializeTo("fileBrowser", objectWriter, urlBuilder);

            if (Encode.HasValue && !Encode.Value)
            {
                objectWriter.Append("encoded", Encode.Value);
            }

            if (StyleSheets.Items.Any())
            {
                var isSecured   = ViewContext.HttpContext.Request.IsSecureConnection;
                var canCompress = ViewContext.HttpContext.Request.CanCompress();

                var mergedGroup = resolver.Resolve(new ResolverContext
                {
                    ContentType         = "text/css",
                    HttpHandlerPath     = WebAssetHttpHandler.DefaultPath,
                    IsSecureConnection  = isSecured,
                    SupportsCompression = canCompress
                }, new WebAssetCollection("~/Content")
                {
                    StyleSheets
                });

                objectWriter.AppendCollection("stylesheets", mergedGroup);
            }

            Localization.SerializeTo("localization", objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 22
0
        private void XmppClient_OnRosterItemUpdated(object Sender, RosterItem Item)
        {
            string[] TabIDs = this.GetTabIDs();
            if (TabIDs.Length > 0)
            {
                string Json = JSON.Encode(new KeyValuePair <string, object>[]
                {
                    new KeyValuePair <string, object>("bareJid", Item.BareJid),
                    new KeyValuePair <string, object>("html", this.RosterItemsHtml(new RosterItem[] { Item }, new PresenceEventArgs[0]))
                }, false);

                ClientEvents.PushEvent(TabIDs, "UpdateRosterItem", Json, true, "User");
            }
        }
Ejemplo n.º 23
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            var objectWriter = ClientSideObjectWriterFactory.Create(Id, "tRangeSlider", writer);

            objectWriter.Start();

            SerializeProperties(objectWriter);

            ClientEvents.SerializeTo(objectWriter);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }
Ejemplo n.º 24
0
        private async Task Push(DateTime Timestamp, string Message, string Function, bool CloseIfNoTabs)
        {
            try
            {
                DateTime Now = DateTime.Now;

                if ((Now - this.tabIdTimestamp).TotalSeconds > 2 || this.tabIds is null || this.tabIds.Length == 0)
                {
                    this.tabIds         = ClientEvents.GetTabIDsForLocation(this.resource, true, "SnifferId", this.snifferId);
                    this.tabIdTimestamp = Now;
                }

                if (this.feedbackCheck && Message.StartsWith("{") && Message.EndsWith("}"))
                {
                    try
                    {
                        object Parsed = JSON.Parse(Message);
                        if (Parsed is IDictionary <string, object> Obj &&
                            Obj.TryGetValue("data", out object Temp) &&
                            Temp is IDictionary <string, object> Obj2 &&
                            Obj2.TryGetValue("timestamp", out object Timestamp2) &&
                            Obj2.TryGetValue("message", out object Message2) &&
                            (this.outgoing?.ContainsKey(this.ToJson(Timestamp2, Message2)) ?? true))
                        {
                            return;
                        }
                    }
                    catch (Exception)
                    {
                        // Ignore
                    }
                }

                string Data = this.ToJson(XML.Encode(Timestamp), Message);

                this.outgoing?.Add(Data, true);

                int Tabs = await ClientEvents.PushEvent(this.tabIds, Function, Data, true, this.userVariable, this.privileges);

                if (CloseIfNoTabs && Tabs <= 0 && (Now - this.created).TotalSeconds >= 5)
                {
                    await this.Close();
                }
            }
            catch (Exception ex)
            {
                Log.Critical(ex);
            }
        }
Ejemplo n.º 25
0
    //void MakeBlock(int id, string[] bdata, List<Block> block)
    void MakeBlock(int id, string[] bdata, Dictionary <int, Block> block)
    {
        Block b = new Block();

        SetBlock(id, bdata, b);

        b.loc_i   = b.loc;
        b.dir_i   = b.dir;
        b.angle_i = b.angle;

        block[b.id] = b;
        //block.Add (b);

        ClientEvents.OnBlockDetected(id);
    }
Ejemplo n.º 26
0
    private void ProcessPackets()
    {
        if (UnityClient.PacketsToProccess.Count > 0)
        {
            // Are we recieving an asset ? (We wait to recieve it all to process other stuff)
            var missingAssets    = AssetHandler.WaitingForAssets.ToArray();
            var packetsToProcess = UnityClient.PacketsToProccess.ToArray();

            // Not an asset, just process the packet
            var packet = UnityClient.PacketsToProccess[0];
            Debug.Log("Calling " + packet.GetType().Name);
            ClientEvents.Call(packet);
            UnityClient.PacketsToProccess.RemoveAt(0);
            Debug.Log("Called");
        }
    }
Ejemplo n.º 27
0
        private void XmppClient_OnStateChanged(object Sender, XmppState NewState)
        {
            if (NewState == XmppState.Offline || NewState == XmppState.Error || NewState == XmppState.Connected)
            {
                string[] TabIDs = this.GetTabIDs();
                if (TabIDs.Length > 0 && !(Gateway.XmppClient is null))
                {
                    string Json = JSON.Encode(new KeyValuePair <string, object>[]
                    {
                        new KeyValuePair <string, object>("html", this.RosterItemsHtml(Gateway.XmppClient.Roster, Gateway.XmppClient.SubscriptionRequests))
                    }, false);

                    ClientEvents.PushEvent(TabIDs, "UpdateRoster", Json, true, "User");
                }
            }
        }
Ejemplo n.º 28
0
        private async Task <bool> Test(string TabID, string DomainName)
        {
            ClientEvents.PushEvent(new string[] { TabID }, "ShowStatus", "Testing " + DomainName + "...", false, "User");

            this.token = Hashes.BinaryToString(Gateway.NextBytes(32));

            using (HttpClient HttpClient = new HttpClient()
            {
                Timeout = TimeSpan.FromMilliseconds(10000)
            })
            {
                try
                {
                    HttpResponseMessage Response = await HttpClient.GetAsync("http://" + DomainName + "/Settings/TestDomainName");

                    if (!Response.IsSuccessStatusCode)
                    {
                        ClientEvents.PushEvent(new string[] { TabID }, "CertificateError", "Domain name does not point to this machine.", false, "User");
                        return(false);
                    }

                    byte[] Bin = await Response.Content.ReadAsByteArrayAsync();

                    string Token = Encoding.ASCII.GetString(Bin);

                    if (Token != this.token)
                    {
                        ClientEvents.PushEvent(new string[] { TabID }, "CertificateError", "Unexpected response returned. Domain name does not point to this machine.", false, "User");
                        return(false);
                    }
                }
                catch (TimeoutException)
                {
                    ClientEvents.PushEvent(new string[] { TabID }, "CertificateError", "Time-out. Check that the domain name points to this machine.", false, "User");
                    return(false);
                }
                catch (Exception ex)
                {
                    ClientEvents.PushEvent(new string[] { TabID }, "CertificateError", "Unable to validate domain name: " + ex.Message, false, "User");
                    return(false);
                }
            }

            ClientEvents.PushEvent(new string[] { TabID }, "ShowStatus", "Domain name valid.", false, "User");

            return(true);
        }
Ejemplo n.º 29
0
        private Task EventsInit()
        {
            // Set up listeners for Client Events
            var clientEvents = new ClientEvents(_client, _logChannel);

            // Set up listeners for Command Events
            var commandEvents = new CommandEvents();

            _client.Ready          += clientEvents.ClientOnReady;
            _client.GuildAvailable += clientEvents.ClientOnGuildAvailable;
            _client.ClientErrored  += clientEvents.ClientOnError;

            Commands.CommandExecuted += commandEvents.CommandOnExecuted;
            Commands.CommandErrored  += commandEvents.CommandOnErrored;

            return(Task.CompletedTask);
        }
Ejemplo n.º 30
0
    //void ParseBlocks(string[] bloques_str, List<Block> blocks){
    void ParseBlocks(string[] bloques_str, Dictionary <int, Block> blocks)
    {
        Dictionary <int, bool> cur = new Dictionary <int, bool> ();

        foreach (string b in bloques_str)
        {
            string[] bdata = b.Split('#');
            if (bdata.Length == 0 || bdata[0] == "")
            {
                continue;
            }
            int id = d2i(bdata[0]);
            cur[id] = true;
            if (!blocks.ContainsKey(id))
            {
                //if (!blocks.Contains (x => x.id == id)) {
                MakeBlock(id, bdata, blocks);
            }
            else
            {
                //UpdateBlock (id, bdata, blocks.Find (x => x.id == id));
                UpdateBlock(id, bdata, blocks[id]);
            }
        }

        Dictionary <int, Block> .KeyCollection k = blocks.Keys;
        for (int i = k.Count - 1; i >= 0; i--)
        {
            //if (!cur.ContainsKey (blocks [i].id)) {
            if (!cur.ContainsKey(k.ElementAt(i)))
            {
                //ClientEvents.OnBlockExit(blocks [i].id);
                //blocks.RemoveAt (i);
                ClientEvents.OnBlockExit(k.ElementAt(i));
                blocks.Remove(k.ElementAt(i));
            }
        }

        /*foreach (int i in blocks.Keys) {
         *      if (!cur.ContainsKey (i)) {
         *              ClientEvents.OnBlockExit(i);
         *              blocks.Remove(i);
         *      }
         * }*/
    }
Ejemplo n.º 31
0
        private void OnNewHandshakeRequest(IAsyncResult ar)
        {
            var parameters = (HandshakeParameter)ar.AsyncState;
            var requestMessageTrimmed = Encoding.UTF8.GetString(parameters.HandshakeBuffer).TrimEnd("\0".ToCharArray());
            var handshakeRequest = new HandshakeRequest(requestMessageTrimmed);
            var handshakeResponse = _handshakeResponseFactory.GetResponse(handshakeRequest);

            if (NewConnection == null)
            {
                parameters.ClientSocket.Close();
                parameters.ClientSocket.Dispose();
                return;
            }

            var messageDecoder = _messageDecoderFactory.GetDecoder(handshakeRequest.Version);
            var clientSocket = new ClientSocket(parameters.ClientSocket,new byte[parameters.MessageSize],_maskingService);
            var messageHandler = new ClientMessageHandler(clientSocket, messageDecoder,new ThreadSafeBuffer());
            var clientEvents = new ClientEvents(messageHandler);
            var clientSender = new ClientSender(messageHandler);
            var connectionInfo = new ConnectionInfo
            {
                Accept = handshakeResponse.AcceptToken,
                Path = handshakeRequest.Path,
                Version = handshakeRequest.Version
            };

            NewConnection(clientSender, clientEvents, connectionInfo);
            parameters.ClientSocket.Send(Encoding.UTF8.GetBytes(handshakeResponse.ToString()));
        }