//
// Copyright (C) 2014 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#if UNITY_ANDROID
namespace GooglePlayGames.BasicApi.Nearby
{
using UnityEngine;
///
/// Dummy implementation of INearbyConnectionClient. This class can be used for testing purposes.
/// It logs messages indicating that its methods have been called.
///
public class DummyNearbyConnectionClient : INearbyConnectionClient
{
///
/// The maximum size of an unreliable message payload.
///
public int MaxUnreliableMessagePayloadLength()
{
return NearbyConnectionConfiguration.MaxUnreliableMessagePayloadLength;
}
///
/// The maximum size of a reliable message payload.
///
public int MaxReliableMessagePayloadLength()
{
return NearbyConnectionConfiguration.MaxReliableMessagePayloadLength;
}
///
/// Logs the message about Reliable call from dummy implementation.
///
public void SendReliable(System.Collections.Generic.List recipientEndpointIds, byte[] payload)
{
OurUtils.Logger.d("SendReliable called from dummy implementation");
}
///
/// Logs the message about Unreliable call from dummy implementation.
///
public void SendUnreliable(System.Collections.Generic.List recipientEndpointIds, byte[] payload)
{
OurUtils.Logger.d("SendUnreliable called from dummy implementation");
}
///
/// Starts advertising for a service.
///
public void StartAdvertising(string name, System.Collections.Generic.List appIdentifiers,
System.TimeSpan? advertisingDuration, System.Action resultCallback,
System.Action connectionRequestCallback)
{
AdvertisingResult obj = new AdvertisingResult(ResponseStatus.LicenseCheckFailed, string.Empty);
resultCallback.Invoke(obj);
}
///
/// Logs the message about StopAdvertising call from dummy implementation.
///
public void StopAdvertising()
{
OurUtils.Logger.d("StopAvertising in dummy implementation called");
}
///
/// Sends a connection request to the specified endpoint.
///
public void SendConnectionRequest(string name, string remoteEndpointId, byte[] payload,
System.Action responseCallback, IMessageListener listener)
{
OurUtils.Logger.d("SendConnectionRequest called from dummy implementation");
if (responseCallback != null)
{
ConnectionResponse obj = ConnectionResponse.Rejected(0, string.Empty);
responseCallback.Invoke(obj);
}
}
///
/// Logs the message about accepts a connection request from the specified endpoint.
///
public void AcceptConnectionRequest(string remoteEndpointId, byte[] payload, IMessageListener listener)
{
OurUtils.Logger.d("AcceptConnectionRequest in dummy implementation called");
}
///
/// Logs the message about StartDiscovery call from dummy implementation.
///
public void StartDiscovery(string serviceId, System.TimeSpan? advertisingTimeout, IDiscoveryListener listener)
{
OurUtils.Logger.d("StartDiscovery in dummy implementation called");
}
///
/// Logs the message about StopDiscovery call from dummy implementation.
///
public void StopDiscovery(string serviceId)
{
OurUtils.Logger.d("StopDiscovery in dummy implementation called");
}
///
/// Logs the message about RejectConnectionRequest call from dummy implementation.
///
public void RejectConnectionRequest(string requestingEndpointId)
{
OurUtils.Logger.d("RejectConnectionRequest in dummy implementation called");
}
///
/// Logs the message about DisconnectFromEndpoint call from dummy implementation.
///
public void DisconnectFromEndpoint(string remoteEndpointId)
{
OurUtils.Logger.d("DisconnectFromEndpoint in dummy implementation called");
}
///
/// Logs the message about StopAllConnections call from dummy implementation.
///
public void StopAllConnections()
{
OurUtils.Logger.d("StopAllConnections in dummy implementation called");
}
///
/// Returns the local endpoint id string.
///
public string LocalEndpointId()
{
return string.Empty;
}
///
/// Returns the local device id string.
///
public string LocalDeviceId()
{
return "DummyDevice";
}
///
/// Returns the app bundle id string.
///
public string GetAppBundleId()
{
return "dummy.bundle.id";
}
///
/// Returns the service id string.
///
public string GetServiceId()
{
return "dummy.service.id";
}
}
}
#endif