lib/app/helper/socket_helper.js
function onPacket(packet) {

		var respond;

		try {
			if (packet.data && typeof packet.data == 'object') {
				packet.data = JSON.undry(packet.data);
			}
		} catch (err) {
			console.log('ERROR UNDRYING PACKET:', err, packet);
			return;
		}

		if (packet.respond) {
			respond = function respond(err, data) {
				var responsePacket = {};

				responsePacket.err = err;
				responsePacket.respond_to = packet.id;
				responsePacket.data = data;

				server.emit('response', responsePacket);
			};
		}

		// See if this is for a specific linkup
		if (packet.link) {
			if (that.linkups[packet.link]) {
				if (packet.stream) {
					that.linkups[packet.link].emit(packet.type, packet.data, packet.stream, respond, null);
				} else {
					that.linkups[packet.link].emit(packet.type, packet.data, respond, null);
				}
			}

			return;
		}

		if (packet.stream) {
			that.emit(packet.type, packet.data, packet.stream, respond, null);
		} else {
			that.emit(packet.type, packet.data, respond, null);
		}
	}
function onPacket(packet) {

		var respond;

		try {
			if (packet.data && typeof packet.data == 'object') {
				packet.data = JSON.undry(packet.data);
			}
		} catch (err) {
			console.log('ERROR UNDRYING PACKET:', err, packet);
			return;
		}

		if (packet.respond) {
			respond = function respond(err, data) {
				var responsePacket = {};

				responsePacket.err = err;
				responsePacket.respond_to = packet.id;
				responsePacket.data = data;

				server.emit('response', responsePacket);
			};
		}

		// See if this is for a specific linkup
		if (packet.link) {
			if (that.linkups[packet.link]) {
				if (packet.stream) {
					that.linkups[packet.link].emit(packet.type, packet.data, packet.stream, respond, null);
				} else {
					that.linkups[packet.link].emit(packet.type, packet.data, respond, null);
				}
			}

			return;
		}

		if (packet.stream) {
			that.emit(packet.type, packet.data, packet.stream, respond, null);
		} else {
			that.emit(packet.type, packet.data, respond, null);
		}
	}
function onPacket ( packet ) { var respond ; try { if ( packet . data && typeof packet . data == 'object' ) { packet . data = JSON . undry ( packet . data ) ; } } catch ( err ) { console . log ( 'ERROR UNDRYING PACKET:' , err , packet ) ; return ; } if ( packet . respond ) { respond = function respond ( err , data ) { var responsePacket = { } ; responsePacket . err = err ; responsePacket . respond_to = packet . id ; responsePacket . data = data ; server . emit ( 'response' , responsePacket ) ; } ; } // See if this is for a specific linkup if ( packet . link ) { if ( that . linkups [ packet . link ] ) { if ( packet . stream ) { that . linkups [ packet . link ] . emit ( packet . type , packet . data , packet . stream , respond , null ) ; } else { that . linkups [ packet . link ] . emit ( packet . type , packet . data , respond , null ) ; } } return ; } if ( packet . stream ) { that . emit ( packet . type , packet . data , packet . stream , respond , null ) ; } else { that . emit ( packet . type , packet . data , respond , null ) ; } }
The function that handles packets
The function that handles packets