<commit_before>﻿using System;
using System.Net;
using System.Windows.Browser;
using System.ComponentModel;

namespace WebSocket4Net.JsBridge
{
    [ScriptableType]
    public class WebSocketBridge
    {
        private WebSocket m_WebSocket;

        private AsyncOperation m_AsyncOper;

        [ScriptableMember(ScriptAlias = "open")]
        public void Open(string uri)
        {
            Open(uri, string.Empty);
        }

        [ScriptableMember(ScriptAlias = "open")]
        public void Open(string uri, string protocol)
        {
            m_AsyncOper = AsyncOperationManager.CreateOperation(null);
            m_WebSocket = new WebSocket(uri, protocol, cookies: HtmlPage.Document.Cookies);
            m_WebSocket.Opened += new EventHandler(m_WebSocket_Opened);
            m_WebSocket.Closed += new EventHandler(m_WebSocket_Closed);
            m_WebSocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(m_WebSocket_MessageReceived);
            m_WebSocket.Open();
        }

        void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {<commit_msg>passed in Origin in JsBridge<commit_after>﻿using System;
using System.Net;
using System.Windows.Browser;
using System.ComponentModel;

namespace WebSocket4Net.JsBridge
{
    [ScriptableType]
    public class WebSocketBridge
    {
        private WebSocket m_WebSocket;

        private AsyncOperation m_AsyncOper;

        [ScriptableMember(ScriptAlias = "open")]
        public void Open(string uri)
        {
            Open(uri, string.Empty);
        }

        [ScriptableMember(ScriptAlias = "open")]
        public void Open(string uri, string protocol)
        {
            m_AsyncOper = AsyncOperationManager.CreateOperation(null);

            //pass in Origin
            var hostName = HtmlPage.Document.DocumentUri.Host;
            var port = HtmlPage.Document.DocumentUri.Port;

            string origin = hostName;

            if (port != 80)
                origin += ":" + port;

            m_WebSocket = new WebSocket(uri, protocol, cookies: HtmlPage.Document.Cookies, origin: origin);
            m_WebSocket.Opened += new EventHandler(m_WebSocket_Opened);
            m_WebSocket.Closed += new EventHandler(m_WebSocket_Closed);
            m_WebSocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(m_WebSocket_MessageReceived);
            m_WebSocket.Open();
        }

        void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
{'fraction_non_alphanumeric': 0.08128469468675655, 'fraction_numerical': 0.0015860428231562252, 'mean_word_length': 2.6939970717423134, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5389450', 'n_tokens_mistral': 684, 'n_tokens_neox': 658, 'n_words': 141}