Пример #1
0
        private void ParseServerMessage(Operatie op)
        {
            switch (op.Denumire)
            {
            case Operatie.DenumireOperatie.OP_SERVER:
            {
                OperatieServer os = op as OperatieServer;
                if (os.OperatiuneServer == OperatieServer.Operatii.SERV_SYNC)
                {
                    string data = os.opData as string;
                    SafeUpdateControl(tbContent, data);
                }
            }
            break;

            case Operatie.DenumireOperatie.OP_INSERARE:
            {
                OperatieInserare oi = op as OperatieInserare;
                int i = oi.InsertPoint.PozitieStart;
                int j = i + oi.InsertPoint.LungimeSelectie;
                SafeInsertContent(oi);
                //string data = tbContent.Text.Substring(0, i) + oi.InsertedText + tbContent.Text.Substring(j);
                //SafeUpdateControl(tbContent, data);
                SafeUpdateControl(tbLog, tbLog.Text + "INSERT recived from " + oi.Token + "\n");
            }
            break;

            default:
                break;
            }
        }
Пример #2
0
        private void ConnectToServer(string token)
        {
            BibliotecaClient.StareClient sc = new StareClient(0, token);
            OperatieServer os = new OperatieServer(token, OperatieServer.Operatii.SERV_CON, sc);

            serverIn.Send(os, "Client " + token + " connect request");
            serverOut.BeginReceive(TimeSpan.FromSeconds(30), serverOut, new AsyncCallback(OnServerMessage));
        }