How to use the ws.port function in ws

To help you get started, we’ve selected a few ws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kevinhikaruevans / uojs2 / src / client / index.js View on Github external
import { createStore, applyMiddleware } from 'redux';
import reducers from './reducers';
import thunk from 'redux-thunk';

// @@@@@
import routes from './routes'
import config from 'config'
import Transport from 'core/transport'
import { Package, HuffmanDecompression } from 'component/helpers'
import manager from 'package/manager'

const history = createHistory();

const transport = new Transport({
    host        : config['ws.client.host'],
    port        : config['ws.port'],
    protocol    : 'binary',
    binaryType  : 'arraybuffer'
});

const middleware = [
    thunk.withExtraArgument(transport),
    router(history)
];

if(__DEVELOPMENT__) {
    middleware.push(
        require('redux-logger')({
            duration    : true,
            diff        : true,
            collapsed   : true
        })
github kevinhikaruevans / uojs2 / src / client / network / gamesocket.js View on Github external
connect() {
        if (this.socket) {
            try {
                this.socket.close();
            }
            catch(e) {
                console.error(e);
            }
        }
        this.store.dispatch(networkActions.setConnected(false, true, null));
        const socket = this.socket = new WebSocket(`ws://${config['ws.client.host']}:${config['ws.port']}`, 'binary');

        socket.binaryType = 'arraybuffer';
        socket.onopen = this.handleOpen;
        socket.onmessage = this.handleMessage;
        socket.onclose = this.handleClose;
        socket.onerror = this.handleError;
    }
github kevinhikaruevans / uojs2 / src / server / index.js View on Github external
require('./env');

const config = require('./../../configs');
const { connect } = require('net');
const { Server } = require('ws');
const debug = require('debug')('proxy:ws');
const uodatareader = require('uodatareader')({
    baseDirectory: config['uo.directory'],
    maps: [
        {fileIndex: 0, mapId: 0, width: 6144, height: 4096},
        {fileIndex: 0, mapId: 1, width: 6144, height: 4096}
    ]
});
const wss = new Server({
    host : config['ws.server.host'],
    port : config['ws.port']
});

const Proxy = require('./socket');

wss.on('connection', ws => {
    debug('Connect protocol %s/%s', ws.protocolVersion, ws.protocol);

    ws.on('message', message => {
        debug('Message length %d, type %s', message.length, typeof message);

        switch(typeof message) {
            case 'string':
                const { event, payout, uid } = JSON.parse(message);

                switch(event) {
                    case 'connect:server':

ws

Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js

MIT
Latest version published 6 months ago

Package Health Score

89 / 100
Full package analysis