role_red.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package model
  2. import (
  3. "roserver/serverproto"
  4. )
  5. type RoleRed struct {
  6. SaveObject
  7. redInfo *serverproto.RoleRed
  8. }
  9. func newRoleRed(r *Role) *RoleRed {
  10. mail := &RoleRed{
  11. SaveObject: SaveObject{
  12. role: r,
  13. },
  14. redInfo: &serverproto.RoleRed{},
  15. }
  16. return mail
  17. }
  18. func (this *RoleRed) Load(msg interface{}) bool {
  19. proRole := msg.(*serverproto.Role)
  20. if proRole.RoleRed != nil {
  21. this.redInfo.IsUnreadMail = proRole.RoleRed.IsUnreadMail
  22. }
  23. return true
  24. }
  25. func (this *RoleRed) Save() {
  26. this.SetDirty(false)
  27. //util.DebugF("uid=%v RoleRed save...", this.role.GetUUid())
  28. saveMsg := &serverproto.SSRoleRedSaveReq{
  29. Red: this.redInfo,
  30. }
  31. this.role.SendDb(saveMsg)
  32. }
  33. func (this *RoleRed) dataChangNtf() {
  34. ackMsg := &serverproto.SCRoleRedNtf{
  35. Red: this.redInfo,
  36. }
  37. this.role.ReplayGate(ackMsg, true)
  38. //util.DebugF("uid=%v dataChangNtf.. msg=%v", this.role.GetUUid(), ackMsg)
  39. }
  40. func (this *RoleRed) SetUnRedMail(val bool, notify bool) {
  41. if this.redInfo.IsUnreadMail != val {
  42. this.redInfo.IsUnreadMail = val
  43. this.SetDirty(true)
  44. if notify {
  45. this.dataChangNtf()
  46. }
  47. }
  48. }