protected override void CheckRequest() { base.CheckRequest(); //save client challenge in _request if (_request == null) { _errorCode = SBErrorCode.Parse; return; } //we first check and get secrete key from database if (!DataOperationExtensions .GetSecretKey(_request.GameName, out _secretKey)) { _errorCode = SBErrorCode.UnSupportedGame; return; } //this is client public ip and default query port SBSession session = (SBSession)_session.GetInstance(); _clientRemoteIP = ((IPEndPoint)session.Socket.RemoteEndPoint).Address.GetAddressBytes(); //TODO //default port should be hton format byte[] defaultPortBytes = BitConverter.GetBytes( ServerListRequest.QueryReportDefaultPort); Array.Reverse(defaultPortBytes); ushort htonDefaultPort = BitConverter.ToUInt16(defaultPortBytes); _gameServerDefaultHostPort = BitConverter.GetBytes(htonDefaultPort); }
public override void DataOperation() { base.DataOperation(); string secretKey; if (!DataOperationExtensions.GetSecretKey(_session.UserInfo.GameName, out secretKey) || secretKey == null) { LogWriter.ToLog(LogEventLevel.Error, "secret key not found!"); return; } _session.UserInfo.SetGameSecretKey(secretKey); }
protected override void DataOperation() { base.DataOperation(); string secretKey; if (!DataOperationExtensions.GetSecretKey(_request.GameName, out secretKey) || secretKey == null) { LogWriter.ToLog(LogEventLevel.Error, "secret key not found!"); _errorCode = ChatError.UnSupportedGame; return; } _session.UserInfo.SetGameSecretKey(secretKey); _session.UserInfo.SetGameName(_request.GameName); // 2. Prepare two keys ChatCrypt.Init(_session.UserInfo.ClientCTX, ChatServer.ClientKey, _session.UserInfo.GameSecretKey); ChatCrypt.Init(_session.UserInfo.ServerCTX, ChatServer.ServerKey, _session.UserInfo.GameSecretKey); }