Files
DefinitelyTyped/types/sockjs/sockjs-tests.ts
Ben Davies 40d73b536f [sockjs] Delete sockjs, rename sockjs-node to sockjs, add tslint.json
@types/sockjs-node was impossible to use since the actual name of the
package it's meant for on npm is sockjs, not sockjs-node. @types/sockjs
already existed, however it was the type declaration file for an old
version of sockjs-client, which already has its own up-to-date type
declaration file under @types/sockjs-client.

Fixes #17112
2017-06-16 00:52:15 -03:00

44 lines
1.2 KiB
TypeScript

import * as sockjs from 'sockjs';
import * as http from 'http';
import * as stream from 'stream';
let server: sockjs.Server;
let serverOptions: sockjs.ServerOptions = {};
// createServer method
server = sockjs.createServer();
server = sockjs.createServer(serverOptions);
// installHandlers method
let httpServer: http.Server = http.createServer();
server.installHandlers(httpServer);
server.installHandlers(httpServer, serverOptions);
// serverOptions
serverOptions.sockjs_url = 'http://cdn.sockjs.org/sockjs-0.3.min.js';
serverOptions.prefix = '/prefix';
serverOptions.response_limit = 128000;
serverOptions.websocket = true;
serverOptions.jsessionid = true;
serverOptions.jsessionid = () => true;
serverOptions.log = (severity: string, message: string) => { };
serverOptions.heartbeat_delay = 25000;
serverOptions.disconnect_delay = 5000;
// Connection
let connection: sockjs.Connection;
// on('connection') passes a sockJS connection
server.on('connection', (conn: sockjs.Connection) => {
connection = conn;
conn = connection;
});
// connection is a ReadWriteStream
let connectionAsReadWrite: NodeJS.ReadWriteStream = connection;
connection.on('data', (message: string) => { });
connection.on('close', () => { });