Click here to Skip to main content
15,997,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using the following java script code to show real time data in my website

What I have tried:

<pre> const socket = io('https://mysocketio.com/', {
                timeout: 2000,
                forceNew: true,
                path: '/socket/',
                query: {
                    token: "AbcD"
                },
                transports: ['websocket'],
                reconnection: true
            });

            socket.on('connect', function () {
               alert('connected');
            });
          

            socket.on('change', function (liveData) {
                alert(liveData);

            });
            socket.on('disconnect', function () {
                alert('disconnect');
            });

The above code is working fine. Now my client wants to do the same in desktop application too. So please help me to show real time data in to desktop application using C# or VB.
Posted
Updated 4-Jun-20 22:10pm

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 
Comments
Member 13147962 5-Jun-20 4:14am    
Hi Thanks for you replay. I've already spend one day for this (I'm new to win forms). Below code is I'm trying...

string socketS = "wss://mysocketio.com/socket/v1/?token=AbcD&EIO=3&transport=websocket";

try
{

var cSocket = IO.Socket(socketS);
cSocket.Connect();

cSocket.On(Socket.EVENT_CONNECT, () =>
{
Console.WriteLine("success");
});

cSocket.On(Socket.EVENT_DISCONNECT, () =>
{

Console.WriteLine("Disconnected");
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

but it returned "Error An item with the same key has already been added ". So please correct me If did anything worng. Thanks.
OriginalGriff 5-Jun-20 4:22am    
That code didn't return that error message.

I'd strongly suggest you start using the debugger to look at what your code is doing while it's running.
Member 13147962 5-Jun-20 9:25am    
But I always got the error "An item with the same key has already been added" (I'm used Quobject.SocketIoClientDotNet.Client library). Anyway I got solution from https://stackoverflow.com/questions/39112800/observing-incoming-websocket-messages-with-reactive-extensions?noredirect=1&lq=1. Thanks for your support.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900