/// <summary> /// 获取Action处理的输出字节流 /// </summary> /// <returns></returns> public static byte[] GetActionResponse(int actionId, BaseUser baseUser, string parameters, out HttpGet httpGet) { string serverHost = string.Format("{0}:{1}", ActionConfig.Current.IpAddress, ActionConfig.Current.Port); string param = string.Format("MsgId={0}&St={1}&Sid={2}&Uid={3}&ActionID={4}{5}", 0, "st", baseUser.GetSessionId(), baseUser.GetUserId(), actionId, parameters); httpGet = new HttpGet(param, baseUser.SocketSid, baseUser.RemoteAddress); BaseStruct baseStruct = FindRoute(ActionConfig.Current.TypeName, httpGet, actionId); SocketGameResponse response = new SocketGameResponse(); baseStruct.UserFactory = uid => { return(baseUser); }; baseStruct.SetPush(); baseStruct.DoInit(); using (baseStruct.RequestLock()) { if (!baseStruct.GetError() && baseStruct.ReadUrlElement() && baseStruct.DoAction() && !baseStruct.GetError()) { baseStruct.BuildPacket(); baseStruct.WriteAction(response); } else { baseStruct.WriteErrorAction(response); } } return(response.ReadByte()); }
protected LoginStatus CheckUser(string sessionID, int userId, out BaseUser gameUser) { gameUser = null; if (UserFactory != null) { gameUser = UserFactory(userId); if (gameUser != null) { string currSid = gameUser.GetSessionId(); if (!string.IsNullOrEmpty(currSid)) { return(currSid == sessionID ? LoginStatus.Success : LoginStatus.Logined); } } } return(LoginStatus.NoLogin); }