var d = require ('dequeue');
var seatStateStore = require("./SeatStateStore");
var dgram = require("dgram");
var FIFO = new d();
fetcher();

var udpserver = dgram.createSocket("udp4");

udpserver.on("message",
    function (msg, rinfo) {
        console.log(FIFO);
        FIFO.push(msg);
    }
);

udpserver.bind(4444);

function fetcher () {
    while (FIFO.length > 0) {
        var msg = FIFO.shift();
        console.log(msg);
        seatStateStore.parseMessage(msg);
        process.nextTick(fetcher);
    }
}

@@ -1,13 +1,112 @@
+/**%0A * Created by tungtouch on 2/5/15.%0A */%0A%0A/*%0A* Listen UDP from Device: 128.199.126.250%0A* */%0A%0A
 var d
+gram
  = requi
@@ -107,17 +107,74 @@
  require
- 
+(%22dgram%22);%0Avar colors = require('colors');%0Avar d = require
 ('dequeu
@@ -180,98 +180,113 @@
 ue')
-;
 %0Avar 
-seatStateStore = require(%22./SeatStateStore%22);%0Avar dgram = require(%22dgram%22
+async = require('async');%0Avar redis = require(%22redis%22);%0Avar rClient = redis.createClient(
 );%0Avar 
-FIFO
+fifo
  = n
@@ -297,33 +297,204 @@
 ();%0A
-fetcher();%0A%0Avar udpserver
+//var ports = %5B4000, 4001, 4002, 3333, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011%5D;%0Avar ports = %5B4444%5D;%0Avar r = 0;%0A%0Avar client
  = d
@@ -515,27 +515,341 @@
 ket(
-%22
+'
 udp4
-%22
+'
 );%0A%0A
+%0A
-udpserver
+rClient.on(%22error%22, function (err) %7B%0A    console.log(%22Error %22 + err);%0A%7D);%0A%0A%0Afetcher();%0Afor(var i=0; i %3C ports.length; i++)%7B%0A%0A%0A    console.log(%22Start listen port %22,i,%22:%22, ports%5Bi%5D);%0A%0A    client.on(%22error%22, function (err) %7B%0A        console.log(%22Server error:%5Cn%22.red + err.stack);%0A        client.close();%0A    %7D);%0A%0A%0A    client
 .on(
@@ -858,20 +858,16 @@
 essage%22,
-%0A   
  functio
@@ -883,32 +883,34 @@
 info) %7B%0A        
+//
 console.log(FIFO
@@ -905,20 +905,31 @@
 ole.log(
-FIFO
+%22Message:%22, msg
 );%0A     
@@ -931,20 +931,20 @@
         
-FIFO
+fifo
 .push(ms
@@ -951,40 +951,48 @@
 g);%0A
+%0A
     %7D
-%0A
 );%0A%0A
-udpserver.bind(4444);%0A
+    client.bind(ports%5Bi%5D);%0A%0A%0A%7D
 %0Afun
@@ -1008,14 +1008,14 @@
 cher
- 
 () %7B%0A
+%0A
     
@@ -1021,20 +1021,20 @@
  while (
-FIFO
+fifo
 .length 
@@ -1037,16 +1037,20 @@
 gth %3E 0)
+%0A   
  %7B%0A     
@@ -1066,12 +1066,12 @@
 g = 
-FIFO
+fifo
 .shi
@@ -1100,50 +1100,21 @@
 log(
-msg);%0A        seatStateStore.parse
+%22
 Message
-(
+: %22, 
 msg)
@@ -1156,10 +1156,76 @@
 ;%0A    %7D%0A
+    //setImmediate(fetcher); //make this function continuously run%0A
 %7D
-%0A

Update UDPefef