[mw_shl_code=delphi,true]procedure TMainFrm.OnHttpSvrRequest(pvRequest: TDiocpHttpRequest);
var
lvJSon: ISuperObject;
lStateCode: Integer;
s, lUID, lToken: string;
lvRawData: ansiString;
begin
//Context Type 返回的是UTF-8的编码
pvRequest.Response.ContentType := 'text/html; charset=utf-8';
//解码Post数据参数
{$IFDEF UNICODE}
pvRequest.DecodePostDataParam(nil);
pvRequest.DecodeURLParam(nil);
{$ELSE}
pvRequest.DecodePostDataParam(false);
pvRequest.DecodeURLParam(false);
{$ENDIF}
if pvRequest.RequestURI = '/login' then //登录验证
begin
SetLength(lvRawData,pvRequest.RawPostData.Size);
pvRequest.RawPostData.Position := 0;
pvRequest.RawPostData.Read(PByte(lvRawData)^, pvRequest.RawPostData.Size);
lvJSon := SO(lvRawData);
//用户密码校验
//校验成功,生成一个串(如guid)返回给客户端,同时发送到gate server, 客户端根据这个串在gate那边校验
DoUserVerify(lvJSon['u'].AsString, lvJSon['p'].AsString, lStateCode, lUID, lToken);
mmoLog.Lines.Add('aa');
end else if pvRequest.RequestURI = '/register' then //新用户注册
begin
SetLength(lvRawData,pvRequest.RawPostData.Size);
pvRequest.RawPostData.Position := 0;
pvRequest.RawPostData.Read(PByte(lvRawData)^, pvRequest.RawPostData.Size);
lvJSon := SO(lvRawData);
//写入redis
FRedisClient.&SET(lvJSon['u'].AsString,lvJSon['p'].AsString);
//通知center server 把新账号入db库
end else if pvRequest.RequestURI = '/register' then //修改密码
begin
end else
begin
//无效操作
lStateCode:= 400;
lUID:= '';
lToken:= '';
end;
lvJSon := SO();
lvJSon.I['s'] := lStateCode;
lvJSon.S['u'] := lUID;
lvJSon.S['t'] := lToken;
s := lvJSon.AsJSon(True, False);
pvRequest.Response.WriteString(s);
//应答完毕,发送回客户端
pvRequest.ResponseEnd;
pvRequest.CloseContext;
end;[/mw_shl_code]