Recent

Author Topic: websockets  (Read 1553 times)

fjabouley

  • Full Member
  • ***
  • Posts: 127
websockets
« on: January 20, 2021, 11:28:44 am »

Hello all !
I'm trying to use an API from OVH to get phone calls, from this page https://events.voip.ovh.net/v2/documentation#!/default/post_session


Using long poll is OK with synapse, I get an ID, and then I make a long poll http get with (.../session/{id}/events/{method})


I'd like to use websockets, but I tried to create one using TTCPBlockSocket from synapse, but it failed.
I know I have to send commands to "upgrade" the connection, but I just cannot manage to connect to the server
Code: Pascal  [Select][+][-]
  1. procedure TOVHWebSocket.Execute;
  2. // TOVHWebSocket is a thread
  3. begin
  4.   Socket := TTCPBlockSocket.Create;
  5.    Socket.Connect(FHost, IntToStr(FPort));
  6.    socket.SSLDoCOnnect;
  7.    Socket.OnStatus := @Self.Status;
  8.  
  9.  
  10.     if socket.LastError<>0 then log(socket.LastErrorDesc);
  11.  
  12.  
  13. while not Terminated do
  14.       begin
  15.       while Socket.CanRead(1000) do
  16.       begin
  17.         sleep(1000);
  18.        log(Socket.RecvString(1000));
  19.       end;
  20.       sleep(100);
  21.       end;
  22.     Socket.Free;
  23. end;
  24.  


I get these errors
Network subsystem is unusable
Error, 10038,Socket operation on nonsocket
Error, 10022,Invalid argument
Error, 10022,Invalid argument


I think I'm not using the right ssl plugin, or I completely misunderstand how it works...


Could someone help me please ?
Thanks !


Best regards

MarkMLl

  • Hero Member
  • *****
  • Posts: 2368
Re: websockets
« Reply #1 on: January 20, 2021, 12:35:00 pm »
Not my field but have you seen the recent thread at https://forum.lazarus.freepascal.org/index.php/topic,48565.msg368600.html ?

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

fjabouley

  • Full Member
  • ***
  • Posts: 127
Re: websockets
« Reply #2 on: January 21, 2021, 09:17:15 am »
Thanks Mark, I'll take a look at the link
Best regards


yus

  • New Member
  • *
  • Posts: 37
Re: websockets
« Reply #3 on: January 26, 2021, 03:13:06 am »

 

TinyPortal © 2005-2018