Sending and receiving events on Socket.IO

Socket.IO allows you to emit and receive custom events. Besides connect, message and disconnect, you can emit custom events

Server

io.on('connection', function (socket) {

    socket.on("msg1", function (from, msg) {
        console.log('I received a message by ', from, ' saying ', msg);
    });

});

Client

$(document).ready(function () {
    var socket = io.connect('http://localhost:14000');
    socket.emit("msg1", "Mahmood", "Hello");
});

References
https://socket.io/docs/#Sending-and-receiving-events