SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 09/05/2018, 08:28 PM   #21
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,836
Reputation: 1405
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Quote:
Originally Posted by AdrianGraber View Post
But what to do when you want to recieve them without pinging the server constantly?
That's what WebSockets are designed for - that gives you a bidirectional data flow mechanism where both ends can push data and trigger interrupts on the opposite end. For this you'd create a WebSocket with `WebSocketClient` which would bind that WebSocket to a callback event - your WebSocket server can then pipe data to the gamemode which would call the callback. You can also send data to the web server via `WebSocketSend`. See an example in the unit tests: https://github.com/Southclaws/pawn-r....pwn#L173-L231

I did also recently update the Redis plugin to use the pub/sub mechanism so that is also a viable option if you want to have multiple consumers or multiple senders of a particular communication channel.
__________________



[HLF]Southclaw is online now   Reply With Quote
Old 10/05/2018, 10:14 PM   #22
AdrianGraber
Big Clucker
 
AdrianGraber's Avatar
 
Join Date: Mar 2013
Location: Germany
Posts: 97
Reputation: 102
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Quote:
Originally Posted by [HLF]Southclaw View Post
That's what WebSockets are designed for - that gives you a bidirectional data flow mechanism where both ends can push data and trigger interrupts on the opposite end. For this you'd create a WebSocket with `WebSocketClient` which would bind that WebSocket to a callback event - your WebSocket server can then pipe data to the gamemode which would call the callback. You can also send data to the web server via `WebSocketSend`. See an example in the unit tests: https://github.com/Southclaws/pawn-r....pwn#L173-L231

I did also recently update the Redis plugin to use the pub/sub mechanism so that is also a viable option if you want to have multiple consumers or multiple senders of a particular communication channel.
Oh, I didn't noticed that the plugin already supports WebSockets, my bad. I think for most things WebSockets might do the job then.

For things that only need simple messages back and forth, it seems this is pretty much the best solution available at the moment, well done.
AdrianGraber is offline   Reply With Quote
Old 17/05/2018, 01:35 PM   #23
pawnoholic
Big Clucker
 
Join Date: Oct 2017
Posts: 68
Reputation: 3
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Is it possible to implement HTTP authentication with Rest API?
__________________
GitHub: @pawnoholic
pawnoholic is online now   Reply With Quote
Old 17/05/2018, 03:36 PM   #24
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,836
Reputation: 1405
Default Re: HTTP(S) Requests+JSON Plugin - Make HTTP(S) Requests with JSON

Quote:
Originally Posted by pawnoholic View Post
Is it possible to implement HTTP authentication with Rest API?
Yes you can either pass the key as a query `?key=123` or add it as a HTTP header.
__________________



[HLF]Southclaw is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSON and SAMP HTTP davidbull Scripting Help 0 05/09/2016 06:07 AM
[Plugin] SAMPSON - A JSON plugin for SA-MP KingHual Plugin Development 25 15/08/2016 04:40 PM
[HELP] Vehicles.json don't load Stefand Scripting Help 1 21/02/2012 02:19 PM
HTTP() callback won't fire, + server crash using HTTP() KoczkaHUN Bug Reports 6 14/12/2011 09:35 AM
vehicles.json help plz sherlock Server Support 3 02/01/2011 12:41 PM


All times are GMT. The time now is 10:29 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.