Communicating with external applications

FrohmanFrohman Join Date: 2010-12-25 Member: 75933Members
Hey, I was just wondering if there's a fast way to communicate with external applications (other than simply writing to a file).
A friend noted the possibility of using a socket -- is there a sockets interface exposed in the NS2 Lua environment?

Comments

  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    Nope. NS2 essentially operates in a sandbox. If it didn't, this would be a potential security exploit that a malicious mod could take advantage of, which would be quite bad.
  • FrohmanFrohman Join Date: 2010-12-25 Member: 75933Members
    Hmm, I assume scripts cannot write to files either, then (even within the NS2 directory)?
    Maybe a HTTP request could work.

    I'm just looking for a safe way for a script within NS2 to talk to an external script - writing to a file and having the external script read from it wouldn't work well for the angle and positional data frequency I'd imagine; or at the very least, it'd be very inefficient.

    A local UDP or even TCP socket would be perfect (not entirely sure how this could pose a major security threat all things considered, but I believe you), but given the lack of that capability, I wonder if the references I'm finding to Shared.SendHTTPRequest would allow a client script to send data locally to an application acting like a HTTP server - alas I've found the documentation fairly hit-and-miss so I've not had much luck exploring it.

    For what it's worth, I'm looking at attempting some Mumble integration; the NS2 client transmits the player's position and the direction they're viewing, and the Mumble plugin side takes this, and passes it on to the Mumble server which uses it to produce positional audio effects for people who are playing, are in the Mumble channel and have positional audio enabled.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    HTTP requests and writing to a file is the only way really.
  • FrohmanFrohman Join Date: 2010-12-25 Member: 75933Members
    edited June 2014
    Out of the two, if HTTP requests (only outgoing is needed) are still supported, they'd easily be the best way to do it.
    The extra fluff of a HTTP request vs just sending what I need over a socket shouldn't mean too much considering its over localhost.

    Is there much documentation on using sendHTTPRequest? I'm in the process of searching for any references to it in existing game lua code.

    Yeah looking at the results, it appears that this would be by far the best way of getting the data out. The only big issue then is that I doubt this could be run client side.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited June 2014
    Find in files and
    {
                "name": "Shared.SendHTTPRequest",
                "arguments": [
                    {
                        "type": "string",
                        "name": "url"
                    },
                    {
                        "type": "string",
                        "name": "method"
                    },
                    {
                        "type": "table",
                        "name": "params"
                    },
                    {
                        "type": "function",
                        "name": "callback"
                    }
                ]
            },
            {
                "name": "Shared.GetHTTPRequest",
                "arguments": [
                    {
                        "type": "string",
                        "name": "url"
                    }
                ],
                "results": [
                    {
                        "type": "string"
                    }
                ]
            },
    
  • joohoo_n3djoohoo_n3d Join Date: 2012-10-30 Member: 164703Members, Reinforced - Onos, WC 2013 - Supporter
    its better to communicate in-game...its the only real way to communicate with your whole team and it works fine without using additional cpu or ram.
  • FrohmanFrohman Join Date: 2010-12-25 Member: 75933Members
    joohoo_n3d wrote: »
    its better to communicate in-game...its the only real way to communicate with your whole team and it works fine without using additional cpu or ram.

    Not really arguing the merits or downsides of using external voice comms in pub games here.
  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    edited June 2014
    joohoo_n3d wrote: »
    its better to communicate in-game...its the only real way to communicate with your whole team and it works fine without using additional cpu or ram.

    You are talking about a completely different thing.
  • FrohmanFrohman Join Date: 2010-12-25 Member: 75933Members
    I'd be right in assuming there's no way to run a script entirely client side (without whitelisting, or workshop subscription by the server itself)?
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    Frohman wrote: »
    I'd be right in assuming there's no way to run a script entirely client side (without whitelisting, or workshop subscription by the server itself)?

    Yeah you are right.
Sign In or Register to comment.