protected override async void Run(Session session, C2G_AddUserMessage message, Action <G2C_AddUserMessage> reply) { G2C_AddUserMessage response = new G2C_AddUserMessage(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserMessage relationInfo = ComponentFactory.Create <UserMessage>(); relationInfo._ByInvAccountID = message.ByAccount; relationInfo._InvAccountID = message.Account; relationInfo._SendDate = message.SendDate; relationInfo._State = 1; relationInfo._Message = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.Message); await dBProxyComponent.Save(relationInfo); //TODO 如果对方在线就添加好友信息的聊天日期数据ID列表并提醒用户,如果对方不在线则添加到留言消息列表 reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_AddUserProductRecord message, Action <G2C_AddUserProductRecord> reply) { G2C_AddUserProductRecord response = new G2C_AddUserProductRecord(); response.IsOk = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); UserProductRecord UserProductRecord = ComponentFactory.Create <UserProductRecord>(); UserProductRecord._AccountID = message.AccountID; UserProductRecord._InfoID = message.InfoID; UserProductRecord._ProductID = message.ProductID; UserProductRecord._Level = message.Level; UserProductRecord._StartDate = message.StartDate; UserProductRecord._EndDate = message.EndDate; UserProductRecord._RightCodeList = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.RightCodeList); UserProductRecord._BuyType = message.BuyType; UserProductRecord._Price = message.Price; response.IsOk = true; await dBProxyComponent.Save(UserProductRecord); await dBProxyComponent.SaveLog(UserProductRecord); reply(response); } catch (Exception e) { response.IsOk = false; response.Message = "数据库异常"; ReplyError(response, e, reply); } }
/// <summary> /// 查询用户画像表 /// </summary> async void QueryUserPortrait() { try { G2C_QueryUserPortrait AccountInfo = (G2C_QueryUserPortrait)await SessionComponent.Instance.Session.Call(new C2G_QueryUserPortrait() { AccountID = AccountID, }); PortraitList = RepeatedFieldAndListChangeTool.RepeatedFieldToList(AccountInfo.PortraitList); } catch (Exception e) { Debug.Log("UserPortraitComponent QueryUserPortrait" + e.Message); } }
/// <summary> /// 查询用户地址表 /// </summary> async void QueryMainAccount() { try { G2C_QueryUserAdress AccountInfo = (G2C_QueryUserAdress)await SessionComponent.Instance.Session.Call(new C2G_QueryUserAdress() { AccountID = AccountID, InfoID = InfoID, }); AddressList = RepeatedFieldAndListChangeTool.RepeatedFieldToList(AccountInfo.AdressList); } catch (Exception e) { Debug.Log("UserAddressComponent QueryMainAccount" + e.Message); } }
protected override async void Run(Session session, C2G_AddChatRoomMessage message, Action <G2C_AddChatRoomMessage> reply) { G2C_AddChatRoomMessage response = new G2C_AddChatRoomMessage(); response.IsSuccess = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ChatRoomMessage relationInfo = ComponentFactory.Create <ChatRoomMessage>(); relationInfo._InvAccountID = message.AccountID; relationInfo._SendDate = message.SendDate; relationInfo._ChatRoomID = message.ChatRoomID; relationInfo._Message = RepeatedFieldAndListChangeTool.RepeatedFieldToList(message.Message); await dBProxyComponent.Save(relationInfo); //添加到对应的聊天室中,并广播给聊天室中的所有成员 var acounts = await dBProxyComponent.Query <ChatRoom>("{ '_id': " + message.ChatRoomID + "}"); if (acounts.Count > 0) { ChatRoom chatRoom = acounts[0] as ChatRoom; chatRoom._DateMessageIDList.Add(relationInfo._SendDate + "|" + relationInfo.Id); foreach (long item in chatRoom._UserList) { //广播给所有该聊天室用户 Log.Debug(MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "广播给:" + item); } } reply(response); } catch (Exception e) { response.Message = MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + MethodBase.GetCurrentMethod().Name + "好友列表获取或创建失败,服务器维护中。"; ReplyError(response, e, reply); } }