Origin-OS icon indicating copy to clipboard operation
Origin-OS copied to clipboard

[OSL] RTR Hosting Syntax

Open Mistium opened this issue 1 year ago • 3 comments

Users have no way to host RTR websites locally.

def "evalOSL(OSL)"
  run [].append("out = (" ++ OSL ++ ")")
  return out
endef

urls = {
  "/eval":"evalOSL()"
}

/*
// if i receive a request like:
{
  data: {
    endpoint: "/eval",
    parameters: ""
  }
}
*/

if new_network_data (
  if packet.data.type == "rtr" (
    // ensure that the packet is an rtr packet
    
    endpoint = packet.data.endpoint
    parameters = packet.data.parameters

    from = packet.origin
    // get the sender of the packet

    command = urls[endpoint]
    // get the endpoint

    command.replace("/","")
    // remove the slash

    func = Globals().functions[command]
    /* returns a function object
    {
      "type": "function",
      "code": ["run [].append(\"out = (\" ++ OSL ++ \")\")","return out"],
      "parameters": ["OSL"],
      "line": 1,
      "scope": "main"
    }
    */

    from.roturSend(func.run(parameters), packet.source)
  )
  new_network_data = false
  packet = ""
  network_data = ""
)

Mistium avatar Aug 19 '24 07:08 Mistium

I'll have to make this sort of thing possible in CRL, nice job!

Edit: looks like normal rotur, should be easy enough

ThatBeaverDev avatar Aug 19 '24 08:08 ThatBeaverDev

thx!

Mistium avatar Aug 19 '24 12:08 Mistium

still need to add the globals system, but after that, this should be possible #173

Mistium avatar Aug 19 '24 12:08 Mistium

this code now works

Mistium avatar Aug 22 '24 22:08 Mistium