<commit_before>message = require("salvus_message")

sjsc = require("sockjs-client-ws")  #  https://github.com/steerapi/sockjs-client-node

#client = sjsc.create("https://localhost/node")  # doesn't work -- don't know why
client = sjsc.create("http://localhost:5000/node")

walltime = -> (new Date()).getTime()
tm = 0
n = 0

client.on('connection', ->
    console.log("connection established")
    tm = walltime()
    client.write(JSON.stringify(message.execute_code(0,'2+2')))
    )

client.on('data', (msg) ->
    t = walltime() - tm
    n = n + 1
    console.log("#{n}: #{Math.floor(n/t*1000)} tps, #{t} ms -- received some data #{msg}")
    if n == 100
        n = 0
        tm = walltime() # start over
    console.log(msg)
    if JSON.parse(msg).done
        console.log("sending 2+2...")
        client.write(JSON.stringify(message.execute_code(n,'2+2')))
)

client.on('error', (e) -> console.log("something went wrong #{e}"))


<commit_msg>how to use nodejs_client with non-local node.<commit_after>message = require("salvus_message")
sjsc = require("sockjs-client-ws")

#client = sjsc.create("https://localhost/node")  # doesn't work -- don't know why

client = sjsc.create("http://localhost:5000/node")

#client = sjsc.create("http://10.1.1.3:5000/node")

walltime = -> (new Date()).getTime()
tm = 0
n = 0

client.on('connection', ->
    console.log("connection established")
    tm = walltime()
    client.write(JSON.stringify(message.execute_code(0,'2+2')))
    )

client.on('data', (msg) ->
    t = walltime() - tm
    n = n + 1
    console.log("#{n}: #{Math.floor(n/t*1000)} tps, #{t} ms -- received some data #{msg}")
    if n == 100
        n = 0
        tm = walltime() # start over
    console.log(msg)
    if JSON.parse(msg).done
        console.log("sending 2+2...")
        client.write(JSON.stringify(message.execute_code(n,'2+2')))
)

client.on('error', (e) -> console.log("something went wrong #{e}"))



{'fraction_non_alphanumeric': 0.1992734820965231, 'fraction_numerical': 0.027503892060197196, 'mean_word_length': 3.2560706401766004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4483314', 'n_tokens_mistral': 715, 'n_tokens_neox': 679, 'n_words': 137}