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