0.0.47 • Published 4 months ago

msrp-node-lib v0.0.47

Weekly downloads
1
License
MIT
Repository
github
Last release
4 months ago

A MSRP library for NodeJS applications

Initialization

Create the MSRP library with minimal settings:

var msrp = require('msrp-node-lib')({
    host: '127.0.0.1',
    port: 2855,
    traceMsrp: true,
    sessionName: 'user-a',
    acceptTypes: 'text/plain',
    setup: 'active'
});

You can also pass a custom logger to the MSRP library, otherwise the console logging methods are used. Here is an example of passing the custom logger to the MSRP library:

var winston = require('winston');

var msrp = require('msrp-node-lib')(
{
    host: '127.0.0.1',
    port: 2855,
    traceMsrp: true,
    sessionName: 'user-a',
    acceptTypes: 'text/plain',
    setup: 'active'
}, new(winston.Logger)({
    levels: {
        debug: 0,
        info: 1,
        warning: 2,
        error: 3
    }
}));

Start MSRP server:

// create msrp server
var msrpServer = new msrp.Server();

// start server
msrpServer.start();

Events

Socket connected event and MSRP session events:

msrpServer.on('socketConnect', function(session) {
    console.log('MSRP socket connected!');

    // create a session
    var msrpSession = msrp.SessionController.createSession();

    // send a message from this session
    msrpSession.sendMessage('Hello world!', function() {
    	console.log('Message sent!');
    });

    // receive a message for this session
    msrpSession.on('message', function(msg) {
    	console.log('Body: ' + msg.body)
    });

});

Other useful socket events:

msrpServer.on('socketTimeout', function() {
	console.log('MSRP socket timed out');
});

msrpServer.on('socketError', function() {
	console.log('MSRP socket error');
});

msrpServer.on('socketClose', function() {
	console.log('MSRP socket closed');
});
0.0.47

4 months ago

0.0.45

7 months ago

0.0.46

7 months ago

0.0.44

1 year ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.41

3 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

5 years ago

0.0.35

5 years ago

0.0.34

5 years ago

0.0.33

5 years ago

0.0.32

5 years ago

0.0.31

5 years ago

0.0.30

5 years ago

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago