Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var data = JSON.stringify(
- {
- "method" : "users.log_in",
- "params" : {
- "login" : "login",
- "password" : "qwerty"
- },
- });
- var WebSocket = require('ws');
- var ws = new WebSocket('ws://<ip>:<port>/apis');
- ws.on('open', function open() {
- console.log('connected');
- ws.send(data, function ack(error) {
- console.log(error);
- });
- });
- ws.on('message', function incoming(data) {
- console.log(data);
- });
- var io = require('socket.io-client');
- var socket = io('ws://<ip>:<port>', {'path': '/apis', 'transports': ['websocket']});
- socket.on('connect_error', function(err){
- console.log('Connection Failed');
- console.log(err);
- });
- socket.on('connect', function(){
- console.log('Connected');
- });
- socket.on('disconnect', function () {
- console.log('Disconnected');
- });
- socket.send(data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement