YOUPAIBBNIMSessionConfigurator.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // YOUPAIBBNIMSessionConfigurator.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/10/26.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBNIMSessionConfigurator.h"
  9. #import "NIMSessionMsgDatasource.h"
  10. #import "NIMSessionInteractorImpl.h"
  11. #import "NIMCustomLeftBarView.h"
  12. #import "UIView+NIM.h"
  13. #import "NIMMessageModel.h"
  14. #import "NIMGlobalMacro.h"
  15. #import "NIMSessionDataSourceImpl.h"
  16. #import "YOUPAIBBNIMSessionLayoutImpl.h"
  17. #import "NIMSessionTableAdapter.h"
  18. /*
  19. NIMSessionViewController 类关系图
  20. .........................................................................
  21. . .
  22. . .
  23. . . | ---> [NIMSessionDatasource]
  24. . .
  25. . | ---> [NIMSessionInteractor] --> |
  26. .
  27. . | ---> [NIMSessionLayout]
  28. .
  29. [NIMSessionViewController]-------> [NIMSessionConfigurator] -----> |
  30. |
  31. |
  32. |
  33. |
  34. ↓ | ---> [NIMSessionTableAdapter]
  35. [UITableView] .
  36. ↑ .
  37. . .
  38. . .
  39. .......................................................................
  40. */
  41. @interface YOUPAIBBNIMSessionConfigurator()
  42. @property (nonatomic,strong) NIMSessionInteractorImpl *youpaipinteractor;
  43. @property (nonatomic,strong) NIMSessionTableAdapter *youpaiptableAdapter;
  44. @end
  45. @implementation YOUPAIBBNIMSessionConfigurator
  46. - (void)youpaifsetup:(YOUPAIBBNIMSessionViewController *)vc
  47. {
  48. NIMSession *session = vc.session;
  49. id<NIMSessionConfig> sessionConfig = vc.sessionConfig;
  50. UITableView *tableView = vc.tableView;
  51. YOUPAIBBNIMInputView *inputView = vc.youpaipsessionInputView;
  52. NIMSessionDataSourceImpl *datasource = [[NIMSessionDataSourceImpl alloc] initWithSession:session config:sessionConfig];
  53. YOUPAIBBNIMSessionLayoutImpl *layout = [[YOUPAIBBNIMSessionLayoutImpl alloc] initWithSession:session config:sessionConfig];
  54. layout.youpaiptableView = tableView;
  55. layout.youpaipinputView = inputView;
  56. _youpaipinteractor = [[NIMSessionInteractorImpl alloc] initWithSession:session config:sessionConfig];
  57. _youpaipinteractor.delegate = vc;
  58. _youpaipinteractor.dataSource = datasource;
  59. _youpaipinteractor.layout = layout;
  60. [layout setDelegate:_youpaipinteractor];
  61. _youpaiptableAdapter = [[NIMSessionTableAdapter alloc] init];
  62. _youpaiptableAdapter.interactor = _youpaipinteractor;
  63. _youpaiptableAdapter.delegate = vc;
  64. vc.tableView.delegate = _youpaiptableAdapter;
  65. vc.tableView.dataSource = _youpaiptableAdapter;
  66. [vc setInteractor:_youpaipinteractor];
  67. }
  68. - (void)youpaifuc_setup:(YOUPAIBBUCIMP2PSessionVC *)vc
  69. {
  70. NIMSession *session = vc.session;
  71. id<NIMSessionConfig> sessionConfig = vc.sessionConfig;
  72. UITableView *tableView = vc.youpaiptableView;
  73. YOUPAIBBNIMInputView *inputView = vc.youpaipsessionInputView;
  74. NIMSessionDataSourceImpl *datasource = [[NIMSessionDataSourceImpl alloc] initWithSession:session config:sessionConfig];
  75. YOUPAIBBNIMSessionLayoutImpl *layout = [[YOUPAIBBNIMSessionLayoutImpl alloc] initWithSession:session config:sessionConfig];
  76. layout.youpaiptableView = tableView;
  77. layout.youpaipinputView = inputView;
  78. _youpaipinteractor = [[NIMSessionInteractorImpl alloc] initWithSession:session config:sessionConfig];
  79. _youpaipinteractor.delegate = vc;
  80. _youpaipinteractor.dataSource = datasource;
  81. _youpaipinteractor.layout = layout;
  82. [layout setDelegate:_youpaipinteractor];
  83. _youpaiptableAdapter = [[NIMSessionTableAdapter alloc] init];
  84. _youpaiptableAdapter.interactor = _youpaipinteractor;
  85. _youpaiptableAdapter.delegate = vc;
  86. vc.youpaiptableView.delegate = _youpaiptableAdapter;
  87. vc.youpaiptableView.dataSource = _youpaiptableAdapter;
  88. [vc setYoupaipinteractor:_youpaipinteractor];
  89. }
  90. @end