Retrieving a price stream via WebSocket in C#. - page 7

 
Maxim Dmitrievsky:
but how to output them from widget? for example, to save them in a file, all the same it is necessary to make something)

So in the very beginning I wrote, from HTML table cells, by OnChange event (I don't remember the exact name). In short, through DHTML and browser object models. Somebody here has advised to start browser directly in C# program, which makes the task easier. And all widget code is now in my local - can modify.

What to do, - I'm not good at sockets, didn't have to somehow.

 
Yuriy Asaulenko:

So in the very beginning I wrote, from HTML table cells, by OnChange event (I don't remember the exact name). In short, through DHTML and browser object models. Somebody here has advised to start browser directly in C# program, which makes the task easier. And all code of the widget is now in my local - it's possible to modify.

What to do, - I'm not good at sockets, didn't have to somehow.

I don't need to re-invent a wheel and start something somewhere. Everything already exists - WebBrowser object. That's what I was talking about. I thought you were talking about it too. You have to catch the event inside it. Which one - I don't know - I haven't gone into it and I have no time! But the subject is interesting.

 
mmmoguschiy-new:
Everything is already in place - the WebBrowser object. That's what I was talking about. I thought you were talking about it too. Inside it and need to catch the event. Which one - I do not know - I did not go into it and I have no time! But the subject is interesting.

I am aware of it. I also know about it. :) It's practically the equivalent of launching IE.

Although before, some years ago, did through scripts directly in the HTML page, which already interacted with the program.

 
I don't see how a web browser object can be useful - so we create this object, load a page into it, and then what? :)) It's kind of cool. How to access page elements, write the code let's not messages like: "Oh, what an interesting topic, but I now have no time," people have already written 5 and not a single line of code. Or then do not write, that would not be unnecessary information, which have to spend time on processing :)
 
Maxim Dmitrievsky:
I do not buy what can be useful for web browser object - well, we created this object, loaded the page, and then what? :)) Kinda cool. How to access page elements, write the code let's not messages like: "Oh, what an interesting topic, but I now have no time," people have already written 5 and not a single line of code. Or then do not write, that would not be unnecessary information, which would have to spend time on processing :)

The page doesn't need to be loaded to get every new quote - it is loaded once into memory and then updated by internal scripts.

I can't help you with the code, it's not my area. But the tip is right )

 

;)

Really, why reinvent the wheel...

the widget can be easily saved to disk, just like any html page. In the page folder you will find two scripts, faye-client.js and lmax-widget-quotes-v2.min.js

they do all the work...

You are probably able to interact with them via C# applications and the built-in WebBrowser. It is necessary to load a local copy of course, preliminarily having changed Java scripts so that the received data were dumped where it is necessary...

That's all there is to it... take these scripts apart and slightly modify them ;)))

 
Andrey Ziablytsev:

;)

Really, why reinvent the wheel...

the widget can be easily saved to disk, just like any html page. In the page folder you will find two scripts, faye-client.js and lmax-widget-quotes-v2.min.js

they do all the work...

You are probably able to interact with them via C# applications and the built-in WebBrowser. It is necessary to load a local copy of course, preliminarily having changed Java scripts so that the received data were dumped where it is necessary...

that's all there is to it... take these scripts apart and slightly modify them ;)))

...just scroll a mile of scripts to the right... :) no I'm in sockets for now, see if you can, if someone makes it through a web browser, praise be to them :)
 

So far my personal *cough code looks like this, connection to the server is made but nothing is read

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.Net.WebSockets;

namespace LmaxSocket
{
    class Program
    {
        static void Main(string[] args)
        {
            // Создаем локальную конечную точку
            IPAddress ipAddr = IPAddress.Parse("66.175.215.164");
            IPEndPoint endPoint = new IPEndPoint(ipAddr, 443);
            TcpClient newClient = new TcpClient();
            bool conn = false; 

            try
            {
                // Соединяемся с сервером
                newClient.Connect(ipAddr, 443); // В этот момент сокет
                                                // порождает исключение, если
                                                // при соединении возникают проблемы
               conn = newClient.Connected; // проверяем статус соединения
              
               Console.WriteLine(conn.ToString()); // пишем статус соединения          
            }
            catch (SocketException ex)
            {
                Console.WriteLine("Exception: " + ex.ToString());
            }

                   
            try //этот код почему-то не обрабатывается как надо
            {
                NetworkStream tcpStream = newClient.GetStream(); // создаем сетевой поток для перехвата сообщений сокета
                byte[] bytes = new byte[newClient.ReceiveBufferSize];
                int bytesRead = tcpStream.Read(bytes, 0, newClient.ReceiveBufferSize);

                // Строка, содержащая ответ от сервера
                string returnData = Encoding.UTF8.GetString(bytes);
                Console.WriteLine(returnData); // почему-то эта строка не выводсится, и не возникает исключений
            }
            catch (SocketException ex)
            {
                Console.WriteLine("Exception: " + ex.ToString());
            }
        }
    }
}
 

Here's one in the WebBrowser.

The values are readable, but the widget itself is drawn crooked. Maybe someone can fix it.

Files:
 
Event:

Here's one in the WebBrowser.

The values are readable, but the widget itself is drawn crooked. Maybe someone can fix it.

Ooh... cool, thanks. At least I have an example now how to do what to do ) I don't need this widget, it can be removed from the window. The main thing is that the quotes can now be used )
Reason: