Ejemplo n.º 1
0
        }// end MessageFromClient

        private void ProcessGenericOperation(BibliotecaClient.Operatie op)
        {
            switch (op.Denumire)
            {
            case BibliotecaClient.Operatie.DenumireOperatie.OP_SERVER:
                //Operatii client - conectare deconectare
                BibliotecaClient.OperatieServer os = op as BibliotecaClient.OperatieServer;
                ProcessServerOperation(os);
                break;

            case BibliotecaClient.Operatie.DenumireOperatie.OP_INSERARE:
                OperatieInserare oi = op as OperatieInserare;
                ProcessInsertOperation(oi);
                System.Console.WriteLine("Operatie primită: " + op.Denumire.ToString());
                break;

            case BibliotecaClient.Operatie.DenumireOperatie.OP_DEPLASARE:
                System.Console.WriteLine("Operatie primită: " + op.Denumire.ToString());
                break;

            default:
                System.Console.WriteLine("Mesaj invalid receptionat - Operatie necunoscuta");
                break;
            } // end switch
        }
Ejemplo n.º 2
0
        private void ProcessServerOperation(BibliotecaClient.OperatieServer os)
        {
            switch (os.OperatiuneServer)
            {
            case BibliotecaClient.OperatieServer.Operatii.SERV_CON:
            {
                //Conectare client nou
                //Datele atasate sunt o noua stare client
                BibliotecaClient.StareClient sc = os.opData as BibliotecaClient.StareClient;
                //Creaza o coada pentru client si adauga-l la lista
                MessageQueue coadaDedicataClient = initQueue(clientSpecificOutboundBaseQ + sc.Token);
                coadaDedicataClient.Formatter = new BinaryMessageFormatter();
                //sc.QueuePath = coadaDedicataClient + sc.Token;
                //TODO - Autentificare
                clienti[sc.Token] = sc;
                System.Console.WriteLine("Client [" + sc.Token + "] has connected.");

                //Send a SYN message

                BibliotecaClient.OperatieServer reply = new BibliotecaClient.OperatieServer(os.Token, BibliotecaClient.OperatieServer.Operatii.SERV_SYNC, DocumentContent);
                //Message msg = new Message(reply);
                //msg.Label = "SYNC message to " + os.Token;
                System.Console.WriteLine("SYNC transmitted to " + os.Token);
                unicastMessage(os.Token, reply);
            }

            break;

            case BibliotecaClient.OperatieServer.Operatii.SERV_RELEASE:
            {
                //Elimina clientul.
                clienti.Remove(os.Token);
                System.Console.WriteLine("Bye [" + os.Token + "]!");
            }
            break;

            case BibliotecaClient.OperatieServer.Operatii.SERV_SYNC:
            {
                BibliotecaClient.OperatieServer reply = new BibliotecaClient.OperatieServer(os.Token, BibliotecaClient.OperatieServer.Operatii.SERV_SYNC, DocumentContent);
                Message msg = new Message(reply);
                msg.Label = "SYNC message to " + os.Token;
                System.Console.WriteLine("SYNC transmitted to " + os.Token);
                unicastMessage(os.Token, msg);
            }
            break;

            default:
                System.Console.WriteLine("Mesaj invalid receptionat - Operatie server necunoscuta");
                break;
            }
        }