Announcement

Collapse
No announcement yet.

Chat Server & client with Luasocket+Coroutines

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Chat Server & client with Luasocket+Coroutines

    I made this example project this week and I hope you like it. You can use it as a kind of chat server or with a little more code as a game server or whatever. It supports multiple clients (each connection will keep alive until the client get closed). I will show you how to identify multiple clients even if they are connected from the same computer or lan.

    I hope you like it. Comments are accepted :P .

    BTW, I already did other server but with lua lanes + coroutines + luasocket but I'm cleaning the code. If you are interested on it let me know to upload it. And I also have compiled the patched luasocket module but I will try it next week.
    Attached Files

  • #2
    I would be interested in seeing that web.

    Comment


    • #3
      web have I lost the point in this ? just that I see no client side so how do we test it?

      Comment


      • #4
        That's pretty cool, got it working no problems

        Originally posted by gremlin View Post
        web have I lost the point in this ? just that I see no client side so how do we test it?
        The client is on page 2. The way I ran it was to build it then run it, server yes option. start the server, run the program again choose no to server option and it starts the client and then just connect to whatever port ip you set in the server window.

        Regards,

        Comment


        • #5
          thanks for the tip orbital

          Comment


          • #6
            tnx webultra!

            i have a problem
            :(
            there is SendCommand function for clients,but i want to send a command for all clients(from server) and sendCommand function dosent work on server..
            how i can send a command like "unlock" for all of my clients..
            a function like this?
            function SendServerCommand(cmnd)
            --????????
            --myServer:send (cmnd) ????
            --????????
            end

            thanks for helping..

            Comment


            • #7
              Well, all you have to do is a function like this one:

              PHP Code:
              function SendServerCommand(cmnd)
                  
              table.insert(tMsgs, {Client=0Name="System"Msg=tostring(cmnd)});
              end 
              It should work...

              Comment


              • #8
                yeahh!
                it works!!
                :-)

                im working on a lan game!
                i need to have a "servers list" function by which players can finds servers with different ip and ports and then connect to a server,
                also i need a "server name" that shown on "servers list";
                would u plz help me with this?
                tnx..

                Comment


                • #9
                  You can use the computer name instead of the local ip address to connect to the pc where the server is running. If you want to have a "find servers" function then you will have to set always a "ping" port to know if at X ip/pc is running a server (if you don't have the ip or name of the other pcs in your lan you can search info at the msdn for netapi32.dll).

                  Another way is setup a server only to register the game servers available, and your client apps will query this "master" server to get the list of active servers.

                  I can't write the code for you, but I hope it helps.

                  Comment


                  • #10
                    i know that this project is for long time ago , but how can i add chatters list for client ?

                    Comment


                    • #11
                      I would I get the server to reply to just one client ? like when a client sends a command I want to reply to that client only is that possible thanks for the example, I been looking at this since it was posted and only just started to play with it.
                      Plugins or Sources MokoX
                      BunnyHop 2021 Here

                      Comment


                      • #12
                        pls. i need the cleaned code of this Chat system, its actually what i have been looking for. Im also not been able to make the database work, its reading errors. i try creating a database using dbase admin but still reading errors however the chat is working fine. but how to save the transcripts to database is my concern.

                        Comment

                        Working...
                        X