//##################################################################################### // 수신된 메세지 처리 private void WhenRspRegisterCompany(NetMessageStream msg) { RegisterCompanyResults result = (RegisterCompanyResults)msg.ReadInt32(); string name = msg.ReadString(); if (m_registerCompanyCallback != null) { m_registerCompanyCallback(result); m_registerCompanyCallback = null; } }
//##################################################################################### // 수신된 메세지 처리 private NetMessage WhenReqRegisterCompany(ServerVisitor client, NetMessageStream msg) { string userName = msg.ReadData <string>(); string companyName = msg.ReadData <string>().Trim(); RegisterCompanyResults result = RegisterCompanyResults.Fail_Unauthorized; // 인증 var user = this.UserDirector.GetLoginUser(client.ID); if (user != null && user.Name == userName) { user = this.UserDirector.GetAccount(user.Name); if (user != null) { // 이름이 너무 길면 실패 if (companyName.Length > GameValues.MaxCompanyNameLength) { result = RegisterCompanyResults.Fail_InvalidName; } // 등록비가 없으면 실패 else if (user.Resource < GameValues.CompanyRegistrationFee) { result = RegisterCompanyResults.Fail_NotEnoughResource; } // 이름이 중복되면 실패 else if (this.CompanyExists(companyName)) { result = RegisterCompanyResults.Fail_AlreadyExist; } else { // 등록비 차감 user.Resource -= GameValues.CompanyRegistrationFee; // 목록에 등록 m_companyList.Add(new Company() { Name = companyName, Owner = user.Name, }); // 유저의 회사 목록에 등록 user.Companies.Add(companyName); // 성공 result = RegisterCompanyResults.Success; } } } // 등록 결과 알림 NetMessageStream writer = new NetMessageStream(); writer.WriteData((int)result); writer.WriteData(companyName); return(writer.CreateMessage((int)MessageTypes.Rsp_RegisterCompany)); }