de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Need help with HTTP Post request in code
PostPosted: Sun Oct 27, 2019 11:45 pm 
Offline
Regular
I have been writing a client for Odin's Master.

Im having trouble with the HTTP Post request. It appears that the coljure is executed asynchronously that would at least explain the kind of issues Im having.

- Can I make it synchronous instead?
- Is this even the cause of my problem?

This is the exact code in question:

Code:
def jsonRPC2Request = { url, requestId, method, params ->
   def baseUrl = new URL(url)
   def p = groovy.json.JsonOutput.toJson(params)
   def queryString = '{"json-rcp": "2.0", "id": "'+requestId+'", "method": "'+method+'", "params": '+p+'}'
   def connection = baseUrl.openConnection()
   connection.with {
     doOutput = true
   
     requestMethod = 'POST'
     outputStream.withWriter { writer ->
       writer << queryString
     }

     def jsonSlurper = new groovy.json.JsonSlurper()
     def object = jsonSlurper.parseText(content.text)

     return object
   }
}


It is called in various places all over the script however if I put a wait of 2 seconds after the call to the function it works more way more often (not all the time).

The full source code is at GitHub under github.com/OneAndOnlyOdin/VMasterSexScriptsClient/blob/master/main.groovy

Any help would be greatly appreciated.


Top
 Profile Send private message 
 
 Re: Need help with HTTP Post request in code
PostPosted: Fri Nov 01, 2019 12:35 am 
Offline
Regular
It looks like I got it working now.


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.