_loop = function _loop(i) {
                        var packet = packets[i];
                        var lastPacket = i === packets.length - 1;
                        encodePacket(packet, _this3.supportsBinary, function (data) {
                            // always create a new object (GH-437)
                            var opts = {};
                            // have a chance of informing us about it yet, in that case send will
                            // throw an error

                            try {
                                if (usingBrowserWebSocket) {
                                    // TypeError is thrown when passing the second argument on Safari
                                    _this3.ws.send(data);
                                }
                            } catch (e) {}

                            if (lastPacket) {
                                // fake drain
                                // defer to next tick to allow Socket to clear writeBuffer
                                nextTick(function () {
                                    _this3.writable = true;

                                    _this3.emitReserved("drain");
                                }, _this3.setTimeoutFn);
                            }
                        });
                    }
Adds event listeners to the socket

@private