public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { Dictionary <byte, object> m_dic = request.Parameters; object value; string strUserName; string strUserPassword; if (m_dic.TryGetValue((byte)ParameterCode.UserRegiste, out value)) { string strValue = value.ToString(); strValue.Trim(); log.Debug("UserRegisteHandler Get Data:" + strValue); string[] pStr = strValue.Split(','); if (pStr.Length == 2) { strUserName = pStr[0]; strUserPassword = pStr[1]; log.Debug("RegisterName:" + strUserName + "--RegisterPassword:"******"用户名重复!"; return; } else { User newUser = new User(); newUser.Name = strUserName; string strMD5 = MD5Tool.StringToMD5(strUserPassword); newUser.Password = strMD5; int nID = m_mgr.AddUser(newUser); peer.m_curUser = newUser; Dictionary <byte, object> dic = new Dictionary <byte, object>(); dic.Add((byte)ParameterCode.UserRegiste, nID.ToString()); Helper.Log("注册新用户:" + nID.ToString()); response.Parameters = dic; response.ReturnCode = (short)ReturnCode.Success; log.Debug("UserRegiste Success: Add New User:"******"--P:" + strUserPassword + "--MD5:" + strMD5); return; } } } response.ReturnCode = (short)ReturnCode.Error; log.Debug("Login Error"); }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { Dictionary <byte, object> m_dic = request.Parameters; object value; string strUserName; string strUserPassword; if (m_dic.TryGetValue((byte)ParameterCode.UserLogin, out value)) { string strValue = value.ToString(); strValue.Trim(); log.Debug("LoginHandle Get Data:" + strValue); string[] pStr = strValue.Split(','); if (pStr.Length == 2) { strUserName = pStr[0]; strUserPassword = pStr[1]; log.Debug("UserName:" + strUserName + "--UserPassword:"******"Login Success"); return; } } } } response.ReturnCode = (short)ReturnCode.Error; log.Debug("Login Error"); }