What is the process for invoking a websocket from an HTML client?

I have created a WCF Service using netHttpBinding binding and it is hosted on IIS 8 (Windows Server 2012). The interfaces for the service are as follows:

[ServiceContract(CallbackContract = typeof(IDuplexCallbackContract))]
public interface IHelloWebSocket
{
   [OperationContract(IsOneWay = true, Action = "*")] 
   void SayHelloDuplexReceive(string name);
}

[ServiceContract]
public interface IDuplexCallbackContract
{
    [OperationContract(IsOneWay = true, Action = "*")] 
    void SayingHelloSend(string message);
}

Currently, the service class implementation looks like this:

 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
public class HelloWebSocket : IHelloWebSocket
{
    /// <summary>
    /// Call back instance called from service to client.
    /// </summary>
    IDuplexCallbackContract _callback = null;

    public HelloWebSocket()
    {
        _callback =
            OperationContext.Current.GetCallbackChannel<IDuplexCallbackContract>();
    }

    public void SayHelloDuplexReceive(string name)
    {
        _callback.SayingHelloSend("Hello " + name + " by WebSockets");

        //return "Hello " + name;
    }
}

The web configuration is as follows:

<system.serviceModel>
     <services>
       <service name="WebSocketUndersranding.HelloWebSocket">
          <endpoint address=""
            binding="netHttpBinding"
            contract="WebSocketUndersranding.IHelloWebSocket"/>
     </service>
    </services>
     <behaviors>
          <serviceBehaviors>
              <behavior name="">
                  <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                 <serviceDebug includeExceptionDetailInFaults="false" />
             </behavior>
         </serviceBehaviors>
     </behaviors>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
           multipleSiteBindingsEnabled="true" />
   </system.serviceModel>

Now, how do I call the service from an HTML5 client?

The URL of my service can be found at a link.

When trying to write the client code: var websocket = new WebSocket(uri); what should be filled in the "uri" field to successfully call the service? I am unsure and need some guidance.

Thank you, Arijit

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Footer refusing to stay fixed at the bottom of the viewport

Currently, I am utilizing fullpage.js with scrolloverflow.js activated on the second section. In this setup, I would like to have a footer that remains fixed at the bottom of the viewport for the second section only. However, instead of achieving this desi ...

The server's file URLs are modified within the page source of a WordPress site

I've been attempting to integrate Adsense code into a WordPress blog at demonuts.com. I placed the Google code in the TEXT WIDGET provided by WordPress. However, upon running the website, I noticed that the URLs for .js, .css, or .png files are being ...

Encountering ReferenceError while running production build with Webpack

After upgrading to webpack 3.10.0 and Babel 6.26, I managed to fix my dev build but encountered issues with the prod build that I can't seem to resolve. This is the error message I am seeing: ERROR in ./src/index.js Module build failed: ReferenceErr ...

Extracting HTML elements between tags in Node.js is a common task faced

Imagine a scenario where I have a website with the following structured HTML source code: <html> <head> .... <table id="xxx"> <tr> .. </table> I have managed to remove all the HTML tags using a library. Can you suggest w ...

Node Signature Generation for Gigya Comment Notifications

I am currently using the Gigya Comment Notification service within my node application and attempting to generate a valid signature. Despite following the documentation, my code is producing an incorrect hash. Below is the code I am using: var crypto = r ...

PHP array utilized in a dynamic dropdown menu

I am working on creating a PHP array for a select list that has dynamic options populated using JavaScript. My goal is to collect all the options selected and display them on the next page. I was wondering if there is a better way to achieve this task. C ...

Trying to conceal the scrollbar on MS Edge and Firefox?

Currently, I am working on a scrollable menu that requires the scrollbar to be hidden. In Chrome, I have achieved this by using the following code: .menu::-webkit-scrollbar { display: none; } I would like to know if there is an equivalent solution ...

Locate grandchildren elements using getElementById

My task is to modify the content and attributes of the table. The DOM structure is generated by a third-party tool, and I am using JavaScript to make changes in various sections. <div id="myId"> <div> <div> <table&g ...

Sharing data between ejs and javascript files

When using Express, I have encountered an issue with passing a variable to an EJS file called "index.ejs". res.render("index",{passedUser:req.user.alias}) Although I am able to successfully print it using <%=passedUser%> in the EJS file, I require ...

A single element containing two duplicates of identical services

I am encountering an issue with my query builder service in a component where I need to use it twice. Despite trying to inject the service twice, it seems that they just reference each other instead of functioning independently, as shown below: @Component( ...

Populate the dropdown menu with data from a JSON file

Recently, I created a custom JSON file and wanted to populate a select>option using this data. However, I encountered an error message saying: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/.../p ...

Angular - How child components can communicate with their parent components

I'm struggling to understand how to communicate between components and services. :( Even though I've read and tried a lot, some examples work but I still don't grasp why (?). My goal is to have one parent and two child components: dashboa ...

Utilizing AngularJS to organize JSON data and display it in a table format

I currently have a JSON file that I am extracting data from using Angular.js. However, I would like to format the output in a table as depicted below. Here is my HTML and JavaScript code where I am retrieving the JSON data using Angular: https://i.stack. ...

Concentrating on div elements using React

Can the focus() method be used to focus on a div element or any other elements? I have added a tabIndex attribute to a div element: <div ref="dropdown" tabIndex="1"></div> When I click on it, I can see that it gets focused. However, I am att ...

Error: 'delay' is not recognized as a valid function

I'm encountering an error message that reads as follows: $("div.valid_box").html(data.message).css("margin-left", "145px").css("width", "520px").show().delay is not a function [Break On This Error] $(...elay(10000).hide("slow", function() { within m ...

Neglecting the inclusion of a property when verifying for empty properties

In the code snippet below, I have implemented a method to check for empty properties and return true if any property is empty. However, I am looking for a way to exclude certain properties from this check. Specifically, I do not want to include generalReal ...

Creating a personalized aggregation function in a MySQL query

Presenting the data in tabular format: id | module_id | rating 1 | 421 | 3 2 | 421 | 5 3. | 5321 | 4 4 | 5321 | 5 5 | 5321 | 4 6 | 641 | 2 7 | ...

Tips for preserving dynamically generated HTML through Javascript during page reload

I have a straightforward question, but I haven't been able to find a suitable answer. Here's my situation: On my HTML page, I have a form. Using jQuery and AJAX, I submit the form and then use some JavaScript code to change the content of a spec ...

A method for calculating the product of two selected numbers and then adding them together

I am currently working on a form that includes two select options; one for logo design and another for letterhead design. Users should be able to choose the quantity of each design, or both if they wish. For example, a user could select 2 logo designs and ...

Laravel route does not receive a parameter sent via Ajax

I am currently using Laravel 5.8 and implementing a discount code system on my website. To achieve this, I attempted to send data via Ajax in the following manner: $.ajax({ type: 'POST', url: baseurl + 'discount/register', ...