NetTest.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using NRKernal;
  2. using NRKernal.Experimental.NetWork;
  3. using UnityEngine;
  4. /// <summary> A net test. </summary>
  5. public class NetTest : MonoBehaviour
  6. {
  7. /// <summary> The network. </summary>
  8. private NetWorkClient network;
  9. /// <summary> Starts this object. </summary>
  10. private void Start()
  11. {
  12. network = new NetWorkClient();
  13. EnterRoomData data = new EnterRoomData();
  14. data.result = false;
  15. var serilizer = SerializerFactory.Create();
  16. var bnary = serilizer.Serialize(data);
  17. var data2 = serilizer.Deserialize<EnterRoomData>(bnary);
  18. NRDebugger.Info(data2.result);
  19. }
  20. /// <summary> Connects this object. </summary>
  21. public void Connect()
  22. {
  23. network.Connect("192.168.69.213", 6000);
  24. }
  25. /// <summary> Enter room. </summary>
  26. public void EnterRoom()
  27. {
  28. network.EnterRoomRequest();
  29. }
  30. /// <summary> Exit room. </summary>
  31. public void ExitRoom()
  32. {
  33. network.ExitRoomRequest();
  34. }
  35. /// <summary> Updates the camera parameter. </summary>
  36. public void UpdateCameraParam()
  37. {
  38. network.UpdateCameraParamRequest();
  39. }
  40. /// <summary> Disconnects this object. </summary>
  41. public void Disconnect()
  42. {
  43. network.Dispose();
  44. }
  45. }