TestEnter.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Blue;
  2. using Newtonsoft.Json;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class TestEnter : MonoBehaviour,IController
  6. {
  7. public Button mBtn_1;
  8. public Button mBtn_2;
  9. public Button mBtn_3;
  10. public Button mBtn_4;
  11. void Start()
  12. {
  13. mBtn_1.onClick.AddListener(Btn_1);
  14. mBtn_2.onClick.AddListener(Btn_2);
  15. mBtn_3.onClick.AddListener(Btn_3);
  16. mBtn_4.onClick.AddListener(Btn_4);
  17. }
  18. private RTCUserInfo mRTCUserInfo1= new RTCUserInfo()
  19. {
  20. UserID = 456,UserName="我是456",Head=321,Audio = false,Video = false
  21. };
  22. private RTCUserInfo mRTCUserInfo2= new RTCUserInfo()
  23. {
  24. UserID = 789,UserName="我是789",Head=321,Audio = false,Video = false
  25. };
  26. private void Btn_1()
  27. {
  28. this.SendCommand(new OtherUserJoinRoomCommand(mRTCUserInfo1));
  29. }
  30. private void Btn_2()
  31. {
  32. this.SendCommand(new OtherUserLeaveRoomCommand(mRTCUserInfo1));
  33. }
  34. private void Btn_3()
  35. {
  36. this.SendCommand(new OtherUserJoinRoomCommand(mRTCUserInfo2));
  37. }
  38. private void Btn_4()
  39. {
  40. this.SendCommand(new OtherUserLeaveRoomCommand(mRTCUserInfo2));
  41. }
  42. }
  43. public struct OtherUserJoinRoomCommand : ICommand
  44. {
  45. private string mJsonstring;
  46. public OtherUserJoinRoomCommand(RTCUserInfo RTCUserInfo)
  47. {
  48. mJsonstring = JsonConvert.SerializeObject(RTCUserInfo);
  49. }
  50. public void OnExcute()
  51. {
  52. this.SendEvent(new OtherUserJoinRoomEvent(){rtcUserInfoJsonString = mJsonstring});
  53. }
  54. }
  55. public struct OtherUserLeaveRoomCommand : ICommand
  56. {
  57. private string mJsonstring;
  58. public OtherUserLeaveRoomCommand(RTCUserInfo RTCUserInfo)
  59. {
  60. mJsonstring = JsonConvert.SerializeObject(RTCUserInfo);
  61. }
  62. public void OnExcute()
  63. {
  64. this.SendEvent(new OtherLeaveRoomEvent(){rtcUserInfoJsonString = mJsonstring});
  65. }
  66. }