* * *

Author Topic: WebSocket Client?  (Read 1708 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 561
WebSocket Client?
« on: February 26, 2018, 04:18:28 pm »
Hi, I want to connect to a instrustial machine. This machine use rest api to send info. I don't have any problem asking information. I make a Get or Post using a ThttpSend (synapse), and I got the information

But I need use websocket to get  info dynamic. Because, according with manufacter, I can subscribe to some information. I send some info, using a Post then the machine send me information using a websocket.

The documentation of this machine provides some examples in C.Net.
They use https://github.com/sta/websocket-sharp library.

Basically  I need a Websocket client.

Is there any component, or info about WebSocket in fcp/lazarus?

Thanks in advance
/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Leledumbo

  • Hero Member
  • *****
  • Posts: 7908
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: WebSocket Client?
« Reply #1 on: February 26, 2018, 07:36:45 pm »

JD

  • Hero Member
  • *****
  • Posts: 1705
Re: WebSocket Client?
« Reply #2 on: February 26, 2018, 08:45:01 pm »
Have you seen this https://forum.lazarus.freepascal.org/index.php/topic,30649.0.html

I know mORMot has WebSockets. DonAlfredo posted an example some years ago where he used WebSockets with the TVPlanit component.

warleyalex is another member of this forum who uses mORMot websockets. He even has demo videos on Youtube.

JD
« Last Edit: February 26, 2018, 09:58:29 pm by JD »
Windows (10, 7) - Lazarus 1.8/FPC 3.0.4, NewPascal, Delphi
Linux Mint Cinnamon  - Lazarus 1.8/FPC 3.0.4, NewPascal

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

BlueIcaro

  • Hero Member
  • *****
  • Posts: 561
Re: WebSocket Client?
« Reply #3 on: February 27, 2018, 04:29:36 pm »

Have you seen this https://forum.lazarus.freepascal.org/index.php/topic,30649.0.html

I know mORMot has WebSockets. DonAlfredo posted an example some years ago where he used WebSockets with the TVPlanit component.

warleyalex is another member of this forum who uses mORMot websockets. He even has demo videos on Youtube.

JD

Thanks I saw it. I was looking for a component like indy  :-[

Reading the information, I need a cookie and other information, to connect to my machine. So I have to read code, try it, etc.
Not tested: https://github.com/Robert-112/Bauglir-WebSocket-2
I'll  take a look. The post that @JD pointed, and this will be my starting point



/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

JD

  • Hero Member
  • *****
  • Posts: 1705
Re: WebSocket Client?
« Reply #4 on: February 28, 2018, 08:43:51 am »
https://github.com/andremussche/DelphiWebsockets

@BlueIcaro

This one uses Indy but it is not active anymore. I wanted to try and port it to FPC but I was too busy. Maybe you can do it. Or maybo we can convince Remy Lebeau!  :D

JD
Windows (10, 7) - Lazarus 1.8/FPC 3.0.4, NewPascal, Delphi
Linux Mint Cinnamon  - Lazarus 1.8/FPC 3.0.4, NewPascal

Indy 10.6 series; mORMot; Zeos 7.2.1; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

BlueIcaro

  • Hero Member
  • *****
  • Posts: 561
Re: WebSocket Client?
« Reply #5 on: February 28, 2018, 10:11:42 am »
https://github.com/andremussche/DelphiWebsockets

@BlueIcaro

This one uses Indy but it is not active anymore. I wanted to try and port it to FPC but I was too busy. Maybe you can do it. Or maybo we can convince Remy Lebeau!  :D

JD
I downloaded this code, and the code in  C# that I posted in my first post. And other codes, but before ask in this forum I thought that I my be I have to write my own component or unit, because there I didn't find  any suitable solution (for me).

Now I sure that I have to write my own code.

I can connect to my machine using synapse. And I store the cookie. No problem until here. Reading the original C# example from the manufacter (you can see it here: http://developercenter.robotstudio.com/webservice/api_reference, click on examples/ElogSubscriber.cs ), they use a threat to read continuously, so the next step, for me, is make a thread and see what happens. Threads are almost new for me. I did one small application long time ago, and my experience is close to null in that issue.

So I have a huge work ahead. I'll back with news (bad or goog I don't know).

B.R.

/BlueIcaro


Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

rvk

  • Hero Member
  • *****
  • Posts: 3441
Re: WebSocket Client?
« Reply #6 on: February 28, 2018, 10:26:07 am »
Basically  I need a Websocket client.
If you are already using Synapse for THTTPSend, can't you use TTCPBlockSocket directly for the socket communications?

You can also wrap it in a thread like this (TTCPClient):
https://forum.lazarus.freepascal.org/index.php?topic=35603.0
« Last Edit: February 28, 2018, 10:27:59 am by rvk »

BlueIcaro

  • Hero Member
  • *****
  • Posts: 561
Re: WebSocket Client?
« Reply #7 on: March 02, 2018, 11:24:00 am »
Basically  I need a Websocket client.
If you are already using Synapse for THTTPSend, can't you use TTCPBlockSocket directly for the socket communications?

You can also wrap it in a thread like this (TTCPClient):
https://forum.lazarus.freepascal.org/index.php?topic=35603.0

Thanks I'll take a look
/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Remy Lebeau

  • Sr. Member
  • ****
  • Posts: 408
    • Lebeau Software
Re: WebSocket Client?
« Reply #8 on: March 06, 2018, 09:44:29 pm »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 561
Re: WebSocket Client?
« Reply #9 on: March 07, 2018, 07:53:09 am »
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus