Welcome, Guest
Username: Password: Remember me
Components and Libraries for Networking Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

WebSocket Server?! 4 years 11 months ago #13395

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 1
Good day!
Faced with such a situation... Want to raise the webSocket server but as I understand that Indy is ready there is no solution (((( Maybe there are some other options ready-made components?

For example, I tried to write using TidTCPServer - webSocket server:
function handShake(str:string):string;
begin
 Result := TIdEncoderMIME.EncodeBytes( TIdHashSHA1.Create.HashString(str + '258EAFA5-E914-47DA-95CA-C5AB0DC85B11') );
end; 

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
str:AnsiString;
Response: TStringList;
begin
 str:='';
 str:=Acontext.Connection.Socket.ReadLn;

 if str<>'' then form1.Memo1.Lines.Add(str);
 if pos('Sec-WebSocket-Key:',str)=1 then
      begin
        key:=handShake(copy(str,20,length(str)));
        form1.Edit1.text:=key;
      end;

  if pos('Sec-WebSocket-Extensions',str)=1 then
          begin

            form1.Memo2.Lines.Add('Key: '+key);
            Response := TStringList.Create;
            Response.Add('HTTP/1.1 101 Switching Protocols');
            response.Add('Upgrade: websocket');
            response.Add('Connection: Upgrade');
            response.Add('Sec-WebSocket-Accept: '+key);
            response.Add('Sec-WebSocket-Version: 13');

            form1.Memo1.Lines.Add('');
            Acontext.Connection.Socket.WriteLn(response.GetText);


            Response.Free;
          end;


end;

The browser client connects, a handshake occurs, but when it sends a message for example in the form of text:
<script>
var socket = new WebSocket("ws://localhost:9999");
socket.onopen = function() {
  alert("Connected");
};
function mSend(){
socket.send('Hellow');
}
</script>
}

It turns out that it does not reach the server!!! That is, the IdTCPServer1Execute event occurs of course if the client 20 times to send a text something comes predpolagaju in the form of a frame-based Protocol RFC 6455, but the processor to decrypt the frame has not yet been written!
The question in another why the client should send time 20 the message that it reached the server?
I repeat that there is still not clear what kind of frame comes - as another handler for it is not written.

Please Log in or Create an account to join the conversation.

WebSocket Server?! 4 years 11 months ago #13398

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4508
  • Thank you received: 1100
Sir
please any sample project
for LAB testing ?
and more information's like: OS, CT ver, Typhon platform etc
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

WebSocket Server?! 4 years 11 months ago #13400

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 1
win10 x64 CT v6.4
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Tigr.

WebSocket Server?! 4 years 11 months ago #13401

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4508
  • Thank you received: 1100
Sir
we test your project but we can't help :blush:
Please, post to Indy forum for help here
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: Tigr

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

WebSocket Server?! 4 years 11 months ago #13402

  • Tigr
  • Tigr's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 54
  • Thank you received: 1
Thank you! I found a slightly different workaround, but still this issue is worth working on, may be able to create a full free component websocket client-server

Please Log in or Create an account to join the conversation.

Last edit: by Tigr.

WebSocket Server?! 4 years 11 months ago #13403

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4508
  • Thank you received: 1100
Good idea
please check and CT pkgs:
-lz_FpWeb
-pl_LNet
-pl_Synapse
-pl_SynapseVS

for websocket client-server components
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

WebSocket Server?! 4 years 7 months ago #13653

  • George Christodoulou
  • George Christodoulou's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 17
  • Thank you received: 0
If pl_synapse and pl_synapse packages are installed there are two projects in example projects folder .
One for websocketclient and one for websocket server. I have tested them win-win , win-linux and they work fine.
Δεν θα πέθαινα ποτέ για τα πιστεύω μου, γιατί μπορεί να είναι λάθος.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1