aldo

how to get websocket

31 posts in this topic




Welcome to AutoIt and the forum!
What have you tried so far?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello. consider use a lenguage recommended by the page. Maybe javascript otherwise you can use Winhttp UDF but you must use Windows 8 or upper. Also You can do a  trick mixing Javascript and IE.

You mush create it in your account.

Saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is the direct link which I found in the API Playground... It redirects to the login page, a registration will get you the API key :) (as already mentioned by @Danyfirex :P)

 

P.S A word of advice, This forum provides support for problems with AutoIt... not with external matters! You can post questions NOT related to AutoIt in the Language Specific sub-forum or Chat (Not accessible to new members) sub-forum forum :)

P.P.S I just found out there is a Glitter Chat Room (for Binary [That API's provider] developers). Although you need a GitHub account to chat :).

Edited by TheDcoder
Appended P.P.S

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

i know how get API token, but how to use the token to login?

 
 
 
 

Share this post


Link to post
Share on other sites

Token is not for login is for use the API. Look page examples.

Saludos

Share this post


Link to post
Share on other sites

This sample code javascript from websocket

who can help me to convert to au3

 

var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3');

ws.onopen = function(evt) {
    ws.send(JSON.stringify({ticks:'R_100'}));
};

ws.onmessage = function(msg) {
   var data = JSON.parse(msg.data);
   console.log('ticks update: %o', data);
};

 

 

Share this post


Link to post
Share on other sites
1 hour ago, mendrofa said:

 


var ws = new WebSocket('wss://ws.binaryws.com/websockets/v3');

ws.onopen = function(evt) {
    ws.send(JSON.stringify({ticks:'R_100'}));
};

ws.onmessage = function(msg) {
   var data = JSON.parse(msg.data);
   console.log('ticks update: %o', data);
};

How did you do that!? :shocked:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

You can do it using Winhttp (I'm really busy I'll will not traslate to Autoit) .  (make sure using AutoIt for that. it will not be so stable.

https://github.com/uri247/Win81Desktop/tree/master/WinHTTP%20WebSocket%20sample

Saludos

Share this post


Link to post
Share on other sites

ohhh i'm so confused :(

Share this post


Link to post
Share on other sites

this my code

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 233, 192, 124)
$Group1 = GUICtrlCreateGroup("", 8, 8, 297, 217)
$Input1 = GUICtrlCreateInput("9QeuqAtACdcvjIW", 24, 24, 177, 21)
$Button1 = GUICtrlCreateButton("conect socket", 207, 24, 91, 25)
$Edit1 = GUICtrlCreateEdit("", 24, 56, 273, 153)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    case $nmsg = $button1
       tes()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd

func tes()
Local $sIPAddress = "wss://ws.binaryws.com/websockets/v3" ; This IP Address only works for testing on your own computer.
    Local $iPort = guictrlread($input1) ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    sleep(5000)
Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
guictrlsetdata($edit1, $iListenSocket)


   EndFunc

Share this post


Link to post
Share on other sites

NB: Could you please use code tags when posting a script? Makes reading your code much easier ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 233, 192, 124)
$Group1 = GUICtrlCreateGroup("", 8, 8, 297, 217)
$Input1 = GUICtrlCreateInput("9QeuqAtACdcvjIW", 24, 24, 177, 21)
$Button1 = GUICtrlCreateButton("conect socket", 207, 24, 91, 25)
$Edit1 = GUICtrlCreateEdit("", 24, 56, 273, 153)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    case $nmsg = $button1
       tes()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd

func tes()
Local $sIPAddress = "wss://ws.binaryws.com/websockets/v3" ; This IP Address only works for testing on your own computer.
    Local $iPort = guictrlread($input1) ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    sleep(5000)
Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
guictrlsetdata($edit1, $iListenSocket)


   EndFunc

 

Share this post


Link to post
Share on other sites

Thanks :)
But you could as well have modified post #12 ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

can you help me  ? i'm newbie here

@water

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

You need to add some error checking after TCPConnect and TCPListen.
What is the return value and the value of @error?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

like that

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 233, 192, 124)
$Group1 = GUICtrlCreateGroup("", 8, 8, 297, 217)
$Input1 = GUICtrlCreateInput("9QeuqAtACdcvjIW", 24, 24, 177, 21)
$Button1 = GUICtrlCreateButton("conect socket", 207, 24, 91, 25)
$Edit1 = GUICtrlCreateEdit("", 24, 56, 273, 153)
GUICtrlSetData(-1, "")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Select
    case $nmsg = $button1
       tes()
        Case $nmsg =  $GUI_EVENT_CLOSE
            Exit
            endSelect
WEnd

func tes()
Local $sIPAddress = "wss://ws.binaryws.com/websockets/v3" ; This IP Address only works for testing on your own computer.
    Local $iPort = guictrlread($input1) ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Connection successful")
    EndIf

Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)

Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign Local variable to be used by Listening and Client sockets.
    Local $iSocket = 0
    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    MsgBox($MB_SYSTEMMODAL, "", "Client Connected.")
















guictrlsetdata($edit1, $iListenSocket)


   EndFunc

 

Share this post


Link to post
Share on other sites

but still can't to connect to server websocket

Share this post


Link to post
Share on other sites

from your script:

1 hour ago, mendrofa said:

If @error Then         ; The server is probably offline/port is not opened on the server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now