1.1.5 • Published 1 year ago

@foxql/foxql-server v1.1.5

Weekly downloads
53
License
ISC
Repository
github
Last release
1 year ago

foxql-server

Basic websocket server for foxql-peer

Documentation

Install

npm i @foxql/foxql-server

Run

npm run dev

Basic usage

const foxql = require('@foxql/foxql-server');

const server = new foxql.server(connection, [
    'https://foxql-bridge.herokuapp.com' // bridge server url
], '{YOUR_NODE_HOST}');

async function connection(socket)
{
    console.log('New Connection');
}


server.open();  

Change Configurations

const foxql = require('@foxql/foxql-server');

const server = new foxql.server();

server.use('serverOptions',{
    port : 3000,
    host : '0.0.0.0',
    protocol : 'http'
});

server.open();  

Custom socket listener

const foxql = require('@foxql/foxql-server');

const server = new foxql.server(connection);

server.open();  

async function connection(socket)
{
    console.log('user connected!');
}

Custom socket event listener by foxql module

create a 'hello-word.js' and put this codes.

const name = 'hello-word';

exports.listener = (socket, server, data) => {
    const id = socket.id;
    console.log(`Hello ${id}`);
    socket.emit('hello-world', `Your socketId is ${id}`);
}
exports.name = name;

and push your server! This example.

const foxql = require('../index.js');

const server = new foxql.server();

server.pushEvent(
    require('./hello-world.js')
);

server.open();  
1.1.5

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago