Results 1 to 10 of 10

Thread: Is there a websockify implemantation for Pascal?

  1. #1

    Is there a websockify implemantation for Pascal?

    I’m looking for ways of communication between an html/JavaScript client and a Pascal server. The common way of communication for such a client seems to be websockets. Then the missing piece is on the server side. My question therefore is whether there is a “websockify” implementation in (lazarus /free) Pascal?

  2. #2
    IPWorks provide entire WebSockets library that can work with many programming languages including Pascal. And yes you can get their components to work bot with Delphi as with FPC/Lazarus.
    You can find more information about IPWorks WebSockets library here: https://www.nsoftware.com/ipworks/ws/
    Granted this is not Freeware software. Delphi licence costs $799 but their components are well known and highly praised in Delphi community.

    I personally don't have any experience with them because so far I didn't have any need for sophisticated networking in my projects. But since they do offer a 30 day trial period you probably don't have much to lose if you try them out except your time.

  3. #3
    Thank you fore the info. But as my little project is just for fun and without any commercial interest I need to continue my research. Maybe I have to rewrite my pascal program e.g. in node.js. Would be a pity because I like Pascal very much.

  4. #4
    Quote Originally Posted by hgbk View Post
    Maybe I have to rewrite my pascal program e.g. in node.js. Would be a pity because I like Pascal very much.
    Don't give up on pascal yet. There are many components and libraries that allow serving of web content from pascal made application. Believe it or not I have even seen standalone Delphi application that is capable of serving entire WebApplication without even running on server at all.
    In Welcome to PGD thread you mentioned that you are making card based game. A few years ago I have fiddled a bit with IntraWeb component set that shipped with Delphi for free and it might be powerful enough for making a WebBased card game.

    Oh and if you don't mind changing design IDE go check Smart Mobile Studio https://smartmobilestudio.com/trial/ which allows you to create a powerful HTML5 applications by writing them in Pascal language. And yes Smart Mobile Studio even allows you to make WebGL based applications. If you search PGD forum you might stil find an example made by one of our members where entire 3D world is made programaticaly using SMS.

    And yes by searching on internet you can even find some older open-source WebSocket libraries for both Delphi and Lazarus. But I can't say anything about their quality.
    Last edited by SilverWarior; 17-02-2021 at 01:21 PM.

  5. #5
    Quote Originally Posted by SilverWarior View Post
    Don't give up on pascal yet. There are many components and libraries that allow serving of web content from pascal made application. Believe it or not I have even seen standalone Delphi application that is capable of serving entire WebApplication without even running on server at all.
    In Welcome to PGD thread you mentioned that you are making card based game. A few years ago I have fiddled a bit with IntraWeb component set that shipped with Delphi for free and it might be powerful enough for making a WebBased card game.

    Oh and if you don't mind changing design IDE go check Smart Mobile Studio https://smartmobilestudio.com/trial/ which allows you to create a powerful HTML5 applications by writing them in Pascal language. And yes Smart Mobile Studio even allows you to make WebGL based applications. If you search PGD forum you might stil find an example made by one of our members where entire 3D world is made programaticaly using SMS.

    And yes by searching on internet you can even find some older open-source WebSocket libraries for both Delphi and Lazarus. But I can't say anything about their quality.
    I was nearly about to give up on Pascal - but with your advice I found this one: https://github.com/Warfley/LazWebsockets Now it's time to study and test it; I'll keep you updated. Thanks!!
    Last edited by SilverWarior; 17-02-2021 at 03:56 PM. Reason: Fixing error in hyperlink

  6. #6
    Quote Originally Posted by hgbk View Post
    I'll keep you updated. Thanks!!
    I would like that.

  7. #7
    A great job has been done ba Warfley with LazWebsockets. I hope this solves my problem. Unfortunately there is hardly any description beyond the chat example. so my question is whether anybody in this forum has experiences with LazWebsockets. My current question is: When I start and connect a html client several times, how can I differnetiate betwenn the various connections, e.g. to send different messages to each of them? IP-Adress, Port is not the answer if the connections are launched from the same browser. Maybe I should ask this in a separate post..

  8. #8
    A quick look at LazWebsockets source code I can see that LazWebsockets does not contain any session management features. Well at least I don't recognize any.

    This means that you will have to devise your own session management mechanism yourself. You may want to draw your inspiration on how WebServers handle session management.

    In short:
    When client connects to a web server for the first time it assigns client a new unique Session ID. It then stores such SessionID along with other needed information like client address, client usernam etc.
    Then it sends back the client a small package containing the assigned SessionID. The client will then attach this SessionID to each message it sends to server.
    This allows server to recognize from whom the message has come from even if client network address might have changed for some reason. At the same time since server stores clients address along with it SessionID it can then send messages to specific clients at any time and not just as response for clients own message.

    So yeah I'm afraid you might have quite some work to be done before you will be able to work with multiple clients at the same time. But if I remember correctly you said that this is more of a learning thing to your any way.
    So I'm guessing this might be quite interesting learning experience on how session management works and how to implement one yourself.

  9. #9

    Question Lazarus debug

    I've don some progress now: Client (JavaScript) and server (Pascal) are ready now, connection via websockets is established and 1st transfer from client to server work. now it's time to debug ...
    Last edited by hgbk; 13-03-2021 at 12:38 PM.

  10. #10
    Good work.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •