00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "ComplexClientAndServer.h"
00018 #include "ComplexClient.h"
00019 #include "CommonFramework.h"
00020
00021
00022
00035 LOCAL_C void doExampleL()
00036 {
00037 _LIT(KTxtTestingCountServer,"Testing the count server test with 2 client subsessions; these represent independent counters \n\n");
00038 _LIT(KTxtInitCounterAWith,"\nInitialize counter A with : ");
00039 _LIT(KTxtInitCounterBWith,"\nInitialize counter B with : ");
00040 _LIT(KTxtInitCounterFailed,"\nSetting the counter from string failed: non-numeric character detected\n");
00041 _LIT(KTxtInitCounterSucceeded,"\nSetting the counter from string succeededd\n");
00042 _LIT(KTxtGetCounterAValue,"Getting counterA value from server: %d \n");
00043 _LIT(KTxtGetCounterBValue,"Getting counterB value from server: %d \n");
00044 _LIT(KMsgPressAnyKey," (press any key to continue)\n");
00045
00046 TInt ret;
00047
00048
00049 console->Printf(KTxtTestingCountServer);
00050
00051
00052 RCountSession countserv;
00053
00054
00055
00056
00057 User::LeaveIfError(countserv.Connect());
00058
00059
00060
00061
00062 RCountSubSession counterA;
00063 counterA.Open(countserv);
00064 console->Printf(KTxtInitCounterAWith);
00065
00066
00067
00068
00069
00070 _LIT(KTxtIllegalString,"2a");
00071 console->Printf(KTxtIllegalString);
00072 ret = counterA.SetFromString(KTxtIllegalString);
00073 if (ret==ENonNumericString)
00074 {
00075 console->Printf(KTxtInitCounterFailed);
00076 }
00077 else
00078 {
00079 console->Printf(KTxtInitCounterSucceeded);
00080 }
00081
00082
00083
00084
00085 RCountSubSession counterB;
00086 counterB.Open(countserv);
00087 console->Printf(KTxtInitCounterBWith);
00088
00089
00090
00091 _LIT(KTxtLegalString,"100");
00092 console->Printf(KTxtLegalString);
00093 ret = counterB.SetFromString(KTxtLegalString);
00094 if (ret==ENonNumericString)
00095 {
00096 console->Printf(KTxtInitCounterFailed);
00097 }
00098 else
00099 {
00100 console->Printf(KTxtInitCounterSucceeded);
00101 }
00102
00103 console->Printf(KMsgPressAnyKey);
00104 console->Getch();
00105 console->ClearScreen();
00106
00107
00108
00109
00110
00111 console->Printf(KTxtGetCounterAValue,counterA.CounterValue());
00112 console->Printf(KTxtGetCounterBValue,counterB.CounterValue());
00113
00114
00115
00116 _LIT(KTxt1,"\nIncrease counterA by default value (i.e. 1)..\n");
00117 console->Printf(KTxt1);
00118 counterA.Increase();
00119 console->Printf(KTxtGetCounterAValue,counterA.CounterValue());
00120
00121
00122 _LIT(KTxt2,"\nIncrease counterA by 2..\n");
00123 console->Printf(KTxt2);
00124 counterA.IncreaseBy(2);
00125 console->Printf(KTxtGetCounterAValue,counterA.CounterValue());
00126
00127
00128 _LIT(KTxt3,"\nIncrease counterB by default value (i.e. 1)..\n");
00129 console->Printf(KTxt3);
00130 counterB.Increase();
00131 console->Printf(KTxtGetCounterBValue,counterB.CounterValue());
00132
00133
00134 _LIT(KTxt4,"\nIncrease counterA by 7..\n");
00135 console->Printf(KTxt4);
00136 counterA.IncreaseBy(7);
00137 console->Printf(KTxtGetCounterAValue,counterA.CounterValue());
00138
00139
00140 _LIT(KTxt5,"\nIncrease counterB by 5..\n");
00141 console->Printf(KTxt5);
00142 counterB.IncreaseBy(5);
00143 console->Printf(KTxtGetCounterBValue,counterB.CounterValue());
00144
00145
00146 _LIT(KTxt6,"\nDecrease counterA..\n");
00147 console->Printf(KTxt6);
00148 counterA.Decrease();
00149 console->Printf(KTxtGetCounterAValue,counterA.CounterValue());
00150
00151
00152 _LIT(KTxt7,"\nDecrease counterB by 3..\n");
00153 console->Printf(KTxt7);
00154 counterB.DecreaseBy(3);
00155 console->Printf(KTxtGetCounterBValue,counterB.CounterValue());
00156
00157
00158 _LIT(KTxt8,"\nResource count is.. %d \n");
00159 console->Printf(KTxt8,countserv.ResourceCount());
00160
00161
00162
00163 _LIT(KTxt9,"\nClosing counterA and then CounterB..\n");
00164 console->Printf(KTxt9);
00165 counterA.Close();
00166 counterB.Close();
00167
00168
00169
00170 countserv.Close();
00171
00172
00173
00174
00175
00176
00177
00178 }
00179