Autoit v3 and Websocket

@killerfreak · 2018-02-26 15:45 · utopian

Autoit Websocket In this article I want to show you how to connect to the websockets of Steem via Autoit. At the First you most download the 3 UDF´s from my Github Project Websocket Create a Folder and Move the files to it:

like this:

Step 1

now we create a new au3 file and open it. we write now in the first 2 line´s:

#include 
#include 

Now we have to start a session and establish a connection. for this step we wirte now this:

$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)

like this

now we can send the Command to the websocket:

$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')

and this

at last we write now the Output to see the Result and close the Handle

MsgBox(0,"Output",$sPost)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

final

Result: Result

i you want see the Result in a Array you must include the array.au3

for this write under the

#include 

this

#include 

now you can write the script so:

#include 
#include 
#include 
$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)
$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')
$t = _JSONDecode($sPost)
$sPostResult = $t[2][1]
_ArrayDisplay($sPostResult[0])
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

now show the Result better^^ Result

Complet Script:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Killerfreak

 Script Function:
    Connect to a Steem Websocket

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include 
#include 
#include 
$hSession = _WinHttpOpen()
$hConnect = _WinHttpConnect($hSession, "gtg.steem.house",8090)
$name = "killerfreak"
$sPost = _WinHttpSimpleSSLRequest($hConnect, "POST", "", "", '{"jsonrpc": "2.0","id": 7, "method": "get_accounts", "params": [["'&$name&'"]]}')
$t = _JSONDecode($sPost)
$spostresult = $t[2][1]
_ArrayDisplay($spostresult[0])
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hSession)

At the moment i work at a UDF for the websocket.

I Hope you enjoy this Tutorial



Posted on Utopian.io - Rewarding Open Source Contributors


#utopian-io #autoit #devlopment #websocket
Payout: 0.000 HBD
Votes: 4
More interactions (upvote, reblog, reply) coming soon.