INearbyConnectionClient.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // <copyright file="INearbyConnectionClient.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. namespace GooglePlayGames.BasicApi.Nearby
  17. {
  18. using System;
  19. using System.Collections.Generic;
  20. // move this inside IMessageListener and IDiscoveryListener are always declared.
  21. #if UNITY_ANDROID
  22. public interface INearbyConnectionClient
  23. {
  24. int MaxUnreliableMessagePayloadLength();
  25. int MaxReliableMessagePayloadLength();
  26. void SendReliable(List<string> recipientEndpointIds, byte[] payload);
  27. void SendUnreliable(List<string> recipientEndpointIds, byte[] payload);
  28. void StartAdvertising(string name, List<string> appIdentifiers,
  29. TimeSpan? advertisingDuration, Action<AdvertisingResult> resultCallback,
  30. Action<ConnectionRequest> connectionRequestCallback);
  31. void StopAdvertising();
  32. void SendConnectionRequest(string name, string remoteEndpointId, byte[] payload,
  33. Action<ConnectionResponse> responseCallback, IMessageListener listener);
  34. void AcceptConnectionRequest(string remoteEndpointId, byte[] payload,
  35. IMessageListener listener);
  36. void StartDiscovery(string serviceId, TimeSpan? advertisingTimeout,
  37. IDiscoveryListener listener);
  38. void StopDiscovery(string serviceId);
  39. void RejectConnectionRequest(string requestingEndpointId);
  40. void DisconnectFromEndpoint(string remoteEndpointId);
  41. void StopAllConnections();
  42. string GetAppBundleId();
  43. string GetServiceId();
  44. }
  45. #endif
  46. public interface IMessageListener
  47. {
  48. void OnMessageReceived(string remoteEndpointId, byte[] data,
  49. bool isReliableMessage);
  50. void OnRemoteEndpointDisconnected(string remoteEndpointId);
  51. }
  52. public interface IDiscoveryListener
  53. {
  54. void OnEndpointFound(EndpointDetails discoveredEndpoint);
  55. void OnEndpointLost(string lostEndpointId);
  56. }
  57. }