I have a hook method that returns a string, in that method I am using a web request to get a string. Is it possible to delay the methods return until the webrequest has finished processing so I can return the string I pull from the webrequest?
Solved Delaying a return hook for webrequest
Discussion in 'Rust Development' started by k1lly0u, Jun 21, 2016.
-
Wulf Community Admin
Yes, take a look at my Slack and Babel plugins and the plugins using them. You can have a callback inside your plugin that is triggered from the webrequest, and also a callback/Action that is sent back to a plugin if it originated from another.
-
Ok thanks I'll take a look
-
@Wulf, can I get the response using a normal hook call without the direct reference to the plugin?
Ex. Slack.Call("...", "..."); -
Wulf Community Admin
I'm not sure, but testing that now as I encountered an issue with the direct method. -
Wulf Community Admin
Here ya go @k1lly0u:
Code:Action<bool> callback = response => { if (player.ConnectedPlayer == null) return; player.Reply(response ? Lang("ReportSent", player.Id) : Lang("ReportFailed", player.Id)); }; Slack.Call("TicketMessage", string.Join(" ", args), player, channel, callback); -
Legend, thanks
