Forum
× Components and Libraries for Networking Development, discussions, problems and suggestions

Question WebSocket Server?!

  • Tigr
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
1 week 5 days ago #13395 by Tigr
WebSocket Server?! was created by Tigr
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.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
1 week 5 days ago #13398 by Sternas Stefanos
Replied by Sternas Stefanos on topic WebSocket Server?!
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.

  • Tigr
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
1 week 5 days ago - 1 week 5 days ago #13400 by Tigr
Replied by Tigr on topic WebSocket Server?!

File Attachment:

File Name: http_socke...rver.zip
File Size:1,132 KB


win10 x64 CT v6.4
Attachments:
Last edit: 1 week 5 days ago by Tigr.

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

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
1 week 4 days ago - 1 week 4 days ago #13401 by Sternas Stefanos
Replied by Sternas Stefanos on topic WebSocket Server?!
Sir
we test your project but we can't help :blush:
Please, post to Indy forum for help here

PilotLogic Architect and Core Programmer
Last edit: 1 week 4 days ago by Sternas Stefanos.
The following user(s) said Thank You: Tigr

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

  • Tigr
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
1 week 4 days ago - 1 week 4 days ago #13402 by Tigr
Replied by Tigr on topic WebSocket Server?!
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
Last edit: 1 week 4 days ago by Tigr.

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

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
1 week 4 days ago #13403 by Sternas Stefanos
Replied by Sternas Stefanos on topic WebSocket Server?!
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.