예제 #1
0
        private void ComputeSocketCommunication_Client(Socket socket, SocketRequestCommunication comm)
        {
            int terminalId = SocketConnection.FindTerminal(connections, socket);

            if (terminalId != -1)
            {
                var dbManager = DatabaseManager.getInstance();

                if (comm.ticketCompletedId != -1)
                {
                    dbManager.SetTicketAsComplete(comm.ticketCompletedId, terminalId);
                }

                ServerUpdate su = new ServerUpdate();
                ticket       t  = dbManager.GetNextTicket();
                if (t != null)
                {
                    if (dbManager.SetTicketForClient(t.id, terminalId) == -1)
                    {
                    }

                    su.nextTicket = new Models.TerminalTicket(t);
                    updateCllback.TicketsUpdated(su);

                    MediaPlayer.playNextTicket();
                }
                else
                {
                    su.nextTicket = null;
                }

                var serialized = SerializationManager <ServerUpdate> .Serialize(su);

                new Thread(() => SendData(socket, serialized)).Start();
            }
            else
            {
                throw new Exception();
            }
        }
예제 #2
0
        private void ComputeSocketCommunication_Android(Socket originSocket, SocketRequestCommunication comm)
        {
            var    dbManager = DatabaseManager.getInstance();
            ticket newTicket = dbManager.AddNewTicket((int)comm.ticketType);

            if (newTicket == null)
            {
                new Thread(() => SendData(originSocket, "0")).Start();
                return;
            }

            //Print ticket
            var sType = SocketRequestCommunication.getTicketTypeString(comm.ticketType);
            var sNum  = SocketRequestCommunication.getTicketNumber(comm.ticketType, newTicket.number);

            new PrinterManager(sType, sNum).Print();

            //Send confirmation to android
            new Thread(() =>
            {
                Thread.Sleep(_Constants.TIME_WAIT_PRINTER); //give time for the printer to do it's work
                SendData(originSocket, "1");
            }).Start();
        }