public void StartDiscovery(string serviceId, TimeSpan?advertisingTimeout, IDiscoveryListener listener) { Misc.CheckNotNull <string>(serviceId, nameof(serviceId)); Misc.CheckNotNull <IDiscoveryListener>(listener, nameof(listener)); using (NativeEndpointDiscoveryListenerHelper discoveryListener = NativeNearbyConnectionsClient.ToDiscoveryListener(listener)) this.mManager.StartDiscovery(serviceId, NativeNearbyConnectionsClient.ToTimeoutMillis(advertisingTimeout), discoveryListener); }
public void AcceptConnectionRequest(string remoteEndpointId, byte[] payload, IMessageListener listener) { Misc.CheckNotNull <string>(remoteEndpointId, nameof(remoteEndpointId)); Misc.CheckNotNull <byte[]>(payload, nameof(payload)); Misc.CheckNotNull <IMessageListener>(listener, nameof(listener)); Logger.d("Calling AcceptConncectionRequest"); this.mManager.AcceptConnectionRequest(remoteEndpointId, payload, NativeNearbyConnectionsClient.ToMessageListener(listener)); Logger.d("Called!"); }
public void SendConnectionRequest(string name, string remoteEndpointId, byte[] payload, Action <ConnectionResponse> responseCallback, IMessageListener listener) { Misc.CheckNotNull <string>(remoteEndpointId, nameof(remoteEndpointId)); Misc.CheckNotNull <byte[]>(payload, nameof(payload)); Misc.CheckNotNull <Action <ConnectionResponse> >(responseCallback, nameof(responseCallback)); Misc.CheckNotNull <IMessageListener>(listener, nameof(listener)); responseCallback = Callbacks.AsOnGameThreadCallback <ConnectionResponse>(responseCallback); using (NativeMessageListenerHelper messageListener = NativeNearbyConnectionsClient.ToMessageListener(listener)) this.mManager.SendConnectionRequest(name, remoteEndpointId, payload, (Action <long, NativeConnectionResponse>)((localClientId, response) => responseCallback(response.AsResponse(localClientId))), messageListener); }
public void StartAdvertising(string name, List <string> appIdentifiers, TimeSpan?advertisingDuration, Action <AdvertisingResult> resultCallback, Action <ConnectionRequest> requestCallback) { Misc.CheckNotNull <List <string> >(appIdentifiers, nameof(appIdentifiers)); Misc.CheckNotNull <Action <AdvertisingResult> >(resultCallback, nameof(resultCallback)); Misc.CheckNotNull <Action <ConnectionRequest> >(requestCallback, "connectionRequestCallback"); if (advertisingDuration.HasValue && advertisingDuration.Value.Ticks < 0L) { throw new InvalidOperationException("advertisingDuration must be positive"); } resultCallback = Callbacks.AsOnGameThreadCallback <AdvertisingResult>(resultCallback); requestCallback = Callbacks.AsOnGameThreadCallback <ConnectionRequest>(requestCallback); this.mManager.StartAdvertising(name, appIdentifiers.Select <string, NativeAppIdentifier>(new Func <string, NativeAppIdentifier>(NativeAppIdentifier.FromString)).ToList <NativeAppIdentifier>(), NativeNearbyConnectionsClient.ToTimeoutMillis(advertisingDuration), (Action <long, NativeStartAdvertisingResult>)((localClientId, result) => resultCallback(result.AsResult())), (Action <long, NativeConnectionRequest>)((localClientId, request) => requestCallback(request.AsRequest()))); }