NIMSessionConfigurator.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // NIMSessionConfigurator.m
  3. // NIMKit
  4. //
  5. // Created by chris on 2016/11/7.
  6. // Copyright © 2016年 NetEase. All rights reserved.
  7. //
  8. #import "NIMSessionConfigurator.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 "NIMSessionInteractorImpl.h"
  16. #import "NIMSessionDataSourceImpl.h"
  17. #import "NIMSessionLayoutImpl.h"
  18. #import "NIMSessionTableAdapter.h"
  19. /*
  20. NIMSessionViewController 类关系图
  21. .........................................................................
  22. . .
  23. . .
  24. . . | ---> [NIMSessionDatasource]
  25. . .
  26. . | ---> [NIMSessionInteractor] --> |
  27. .
  28. . | ---> [NIMSessionLayout]
  29. .
  30. [NIMSessionViewController]-------> [NIMSessionConfigurator] -----> |
  31. |
  32. |
  33. |
  34. |
  35. ↓ | ---> [NIMSessionTableAdapter]
  36. [UITableView] .
  37. ↑ .
  38. . .
  39. . .
  40. .......................................................................
  41. */
  42. @interface NIMSessionConfigurator()
  43. @property (nonatomic,strong) NIMSessionInteractorImpl *interactor;
  44. @property (nonatomic,strong) NIMSessionTableAdapter *tableAdapter;
  45. @end
  46. @implementation NIMSessionConfigurator
  47. - (void)youpaifsetup:(NIMSessionViewController *)vc
  48. {
  49. NIMSession *session = vc.session;
  50. id<NIMSessionConfig> sessionConfig = vc.sessionConfig;
  51. UITableView *tableView = vc.tableView;
  52. YOUPAINIMInputView *inputView = vc.sessionInputView;
  53. NIMSessionDataSourceImpl *datasource = [[NIMSessionDataSourceImpl alloc] initWithSession:session config:sessionConfig];
  54. NIMSessionLayoutImpl *layout = [[NIMSessionLayoutImpl alloc] initWithSession:session config:sessionConfig];
  55. layout.tableView = tableView;
  56. layout.inputView = inputView;
  57. _interactor = [[NIMSessionInteractorImpl alloc] initWithSession:session config:sessionConfig];
  58. _interactor.delegate = vc;
  59. _interactor.dataSource = datasource;
  60. _interactor.layout = layout;
  61. [layout setDelegate:_interactor];
  62. _tableAdapter = [[NIMSessionTableAdapter alloc] init];
  63. _tableAdapter.interactor = _interactor;
  64. _tableAdapter.delegate = vc;
  65. vc.tableView.delegate = _tableAdapter;
  66. vc.tableView.dataSource = _tableAdapter;
  67. [vc setInteractor:_interactor];
  68. }
  69. - (void)youpaifuc_setup:(YOUPAIUCIMP2PSessionVC *)vc
  70. {
  71. NIMSession *session = vc.session;
  72. id<NIMSessionConfig> sessionConfig = vc.sessionConfig;
  73. UITableView *tableView = vc.tableView;
  74. YOUPAINIMInputView *inputView = vc.sessionInputView;
  75. NIMSessionDataSourceImpl *datasource = [[NIMSessionDataSourceImpl alloc] initWithSession:session config:sessionConfig];
  76. NIMSessionLayoutImpl *layout = [[NIMSessionLayoutImpl alloc] initWithSession:session config:sessionConfig];
  77. layout.tableView = tableView;
  78. layout.inputView = inputView;
  79. _interactor = [[NIMSessionInteractorImpl alloc] initWithSession:session config:sessionConfig];
  80. _interactor.delegate = vc;
  81. _interactor.dataSource = datasource;
  82. _interactor.layout = layout;
  83. [layout setDelegate:_interactor];
  84. _tableAdapter = [[NIMSessionTableAdapter alloc] init];
  85. _tableAdapter.interactor = _interactor;
  86. _tableAdapter.delegate = vc;
  87. vc.tableView.delegate = _tableAdapter;
  88. vc.tableView.dataSource = _tableAdapter;
  89. [vc setInteractor:_interactor];
  90. }
  91. @end