internal ServiceStateChangedEventArgs(WiFiDirectError error, WiFiDirectServiceDiscoveryState state, WiFiDirectServiceType type, string response, WiFiDirectPeer peer) { _error = error; _state = state; _type = type; _response = response; _peer = peer; }
internal static void ThrowWiFiDirectException(int exception) { WiFiDirectError _error = (WiFiDirectError)exception; switch (_error) { case WiFiDirectError.InvalidParameter: throw new InvalidOperationException("Invalid parameter"); case WiFiDirectError.AlreadyInitialized: throw new InvalidOperationException("Already initialized"); case WiFiDirectError.AuthFailed: throw new InvalidOperationException("Authentication failed"); case WiFiDirectError.CommunicationFailed: throw new InvalidOperationException("Communication failed"); case WiFiDirectError.ConnectionCancelled: throw new InvalidOperationException("Connection cancelled"); case WiFiDirectError.ConnectionFailed: throw new InvalidOperationException("Connection failed"); case WiFiDirectError.ConnectionTimeOut: throw new InvalidOperationException("Connection timed out"); case WiFiDirectError.MobileApUsed: throw new InvalidOperationException("Mobile Ap is being used"); case WiFiDirectError.NotInitialized: throw new InvalidOperationException("Not initialized"); case WiFiDirectError.NotPermitted: throw new InvalidOperationException("Not permitted"); case WiFiDirectError.NotSupported: throw new NotSupportedException("Not supported"); case WiFiDirectError.OperationFailed: throw new InvalidOperationException("Operation failed"); case WiFiDirectError.OutOfMemory: throw new InvalidOperationException("Out of memory"); case WiFiDirectError.PermissionDenied: throw new UnauthorizedAccessException("Permission denied (http://tizen.org/privilege/wifidirect)"); case WiFiDirectError.ResourceBusy: throw new InvalidOperationException("Resource is busy"); case WiFiDirectError.TooManyClient: throw new InvalidOperationException("Too many client"); case WiFiDirectError.WiFiUsed: throw new InvalidOperationException("Wi-fi is being used"); } }
private void RegisterConnectionStateChangedEvent() { _connectionStateChangedCallback = (int result, WiFiDirectConnectionState state, string address, IntPtr userData) => { if (_connectionStateChanged != null) { WiFiDirectError res = (WiFiDirectError)result; _connectionStateChanged(null, new ConnectionStateChangedEventArgs(res, state, address)); } }; int ret = Interop.WiFiDirect.SetConnectionChangedCallback(_connectionStateChangedCallback, IntPtr.Zero); if (ret != (int)WiFiDirectError.None) { Log.Error(Globals.LogTag, "Failed to set connection state changed callback, Error - " + (WiFiDirectError)ret); } }
private void RegisterDeviceStateChangedEvent() { _deviceStateChangedCallback = (int result, WiFiDirectDeviceState stateInfo, IntPtr userData) => { if (_deviceStateChanged != null) { WiFiDirectError error = (WiFiDirectError)result; WiFiDirectDeviceState state = stateInfo; _deviceStateChanged(null, new DeviceStateChangedEventArgs(error, state)); } }; int ret = Interop.WiFiDirect.SetDeviceStateChangedCallback(_deviceStateChangedCallback, IntPtr.Zero); if (ret != (int)WiFiDirectError.None) { Log.Error(Globals.LogTag, "Failed to set device state changed callback, Error - " + (WiFiDirectError)ret); } }
private void RegisterPeerFoundEvent() { _peerFoundCallback = (int result, WiFiDirectDiscoveryState stateInfo, string address, IntPtr userData) => { if (_peerFound != null && stateInfo == WiFiDirectDiscoveryState.Found) { WiFiDirectError error = (WiFiDirectError)result; WiFiDirectDiscoveryState state = stateInfo; IntPtr peer; Interop.WiFiDirect.GetDiscoveredPeerInfo(address, out peer); DiscoveredPeerStruct peerStruct = (DiscoveredPeerStruct)Marshal.PtrToStructure(peer, typeof(DiscoveredPeerStruct)); _peerFound(null, new PeerFoundEventArgs(error, state, WiFiDirectUtils.ConvertStructToDiscoveredPeer(peerStruct))); } }; int ret = Interop.WiFiDirect.SetPeerFoundCallback(_peerFoundCallback, IntPtr.Zero); if (ret != (int)WiFiDirectError.None) { Log.Error(Globals.LogTag, "Failed to set Wi-Fi Direct discovery state changed callback, Error - " + (WiFiDirectError)ret); } }
private void RegisterServiceStateChangedEvent() { _serviceStateChangedCallback = (int result, WiFiDirectServiceDiscoveryState stateInfo, WiFiDirectServiceType typeInfo, IntPtr responseData, string address, IntPtr userData) => { if (_serviceStateChanged != null) { WiFiDirectError error = (WiFiDirectError)result; WiFiDirectServiceDiscoveryState state = stateInfo; WiFiDirectServiceType type = typeInfo; string response = Marshal.PtrToStringAnsi(responseData); IntPtr peer; Interop.WiFiDirect.GetDiscoveredPeerInfo(address, out peer); DiscoveredPeerStruct peerStruct = (DiscoveredPeerStruct)Marshal.PtrToStructure(peer, typeof(DiscoveredPeerStruct)); _serviceStateChanged(null, new ServiceStateChangedEventArgs(error, state, type, response, WiFiDirectUtils.ConvertStructToDiscoveredPeer(peerStruct))); } }; int ret = Interop.WiFiDirect.SetServiceStateChangedCallback(_serviceStateChangedCallback, IntPtr.Zero); if (ret != (int)WiFiDirectError.None) { Log.Error(Globals.LogTag, "Failed to set service state changed callback, Error - " + (WiFiDirectError)ret); } }
internal ConnectionStatusChangedEventArgs(WiFiDirectError error, WiFiDirectConnectionState state) { _error = error; _state = state; }
internal ConnectionStateChangedEventArgs(WiFiDirectError error, WiFiDirectConnectionState state, string macAddress) { _error = error; _state = state; _macAddress = macAddress; }
internal DeviceStateChangedEventArgs(WiFiDirectError error, WiFiDirectDeviceState state) { _error = error; _state = state; }
internal PeerFoundEventArgs(WiFiDirectError error, WiFiDirectDiscoveryState state, WiFiDirectPeer peer) { _error = error; _state = state; _peer = peer; }
internal DiscoveryStateChangedEventArgs(WiFiDirectError error, WiFiDirectDiscoveryState state) { _error = error; _state = state; }