DummyNearbyConnectionClient.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // <copyright file="DummyNearbyConnectionClient.cs" company="Google Inc.">
  2. // Copyright (C) 2014 Google Inc.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // </copyright>
  16. #if UNITY_ANDROID
  17. namespace GooglePlayGames.BasicApi.Nearby
  18. {
  19. using UnityEngine;
  20. public class DummyNearbyConnectionClient : INearbyConnectionClient
  21. {
  22. public int MaxUnreliableMessagePayloadLength()
  23. {
  24. return NearbyConnectionConfiguration.MaxUnreliableMessagePayloadLength;
  25. }
  26. public int MaxReliableMessagePayloadLength()
  27. {
  28. return NearbyConnectionConfiguration.MaxReliableMessagePayloadLength;
  29. }
  30. public void SendReliable(System.Collections.Generic.List<string> recipientEndpointIds, byte[] payload)
  31. {
  32. OurUtils.Logger.d("SendReliable called from dummy implementation");
  33. }
  34. public void SendUnreliable(System.Collections.Generic.List<string> recipientEndpointIds, byte[] payload)
  35. {
  36. OurUtils.Logger.d("SendUnreliable called from dummy implementation");
  37. }
  38. public void StartAdvertising(string name, System.Collections.Generic.List<string> appIdentifiers,
  39. System.TimeSpan? advertisingDuration, System.Action<AdvertisingResult> resultCallback,
  40. System.Action<ConnectionRequest> connectionRequestCallback)
  41. {
  42. AdvertisingResult obj = new AdvertisingResult(ResponseStatus.LicenseCheckFailed, string.Empty);
  43. resultCallback.Invoke(obj);
  44. }
  45. public void StopAdvertising()
  46. {
  47. OurUtils.Logger.d("StopAvertising in dummy implementation called");
  48. }
  49. public void SendConnectionRequest(string name, string remoteEndpointId, byte[] payload,
  50. System.Action<ConnectionResponse> responseCallback, IMessageListener listener)
  51. {
  52. OurUtils.Logger.d("SendConnectionRequest called from dummy implementation");
  53. if (responseCallback != null)
  54. {
  55. ConnectionResponse obj = ConnectionResponse.Rejected(0, string.Empty);
  56. responseCallback.Invoke(obj);
  57. }
  58. }
  59. public void AcceptConnectionRequest(string remoteEndpointId, byte[] payload, IMessageListener listener)
  60. {
  61. OurUtils.Logger.d("AcceptConnectionRequest in dummy implementation called");
  62. }
  63. public void StartDiscovery(string serviceId, System.TimeSpan? advertisingTimeout, IDiscoveryListener listener)
  64. {
  65. OurUtils.Logger.d("StartDiscovery in dummy implementation called");
  66. }
  67. public void StopDiscovery(string serviceId)
  68. {
  69. OurUtils.Logger.d("StopDiscovery in dummy implementation called");
  70. }
  71. public void RejectConnectionRequest(string requestingEndpointId)
  72. {
  73. OurUtils.Logger.d("RejectConnectionRequest in dummy implementation called");
  74. }
  75. public void DisconnectFromEndpoint(string remoteEndpointId)
  76. {
  77. OurUtils.Logger.d("DisconnectFromEndpoint in dummy implementation called");
  78. }
  79. public void StopAllConnections()
  80. {
  81. OurUtils.Logger.d("StopAllConnections in dummy implementation called");
  82. }
  83. public string LocalEndpointId()
  84. {
  85. return string.Empty;
  86. }
  87. public string LocalDeviceId()
  88. {
  89. return "DummyDevice";
  90. }
  91. public string GetAppBundleId()
  92. {
  93. return "dummy.bundle.id";
  94. }
  95. public string GetServiceId()
  96. {
  97. return "dummy.service.id";
  98. }
  99. }
  100. }
  101. #endif