public AdvertisementWrapper( WiFiDirectServiceAdvertiser advertiser, WiFiDirectServiceManager manager, string pin = "" ) { this.advertiser = advertiser; this.manager = manager; // Store PIN for "display" config method this.pin = pin; uniqueInternalId = nextId++; // This should fire when the service is created and advertisement has started // It will also fire when the advertisement has stopped for any reason this.advertiser.AdvertisementStatusChanged += OnAdvertisementStatusChanged; // This will fire when an auto-accept session is connected. Advertiser should keep track of the new service session this.advertiser.AutoAcceptSessionConnected += OnAutoAcceptSessionConnected; // This will fire when a session is requested and it must be explicitly accepted or rejected. // The advertiser may need to display a PIN or take user input for a PIN this.advertiser.SessionRequested += OnSessionRequested; }
private WiFiDirectServiceManager() { instance = this; this.rootPage = MainPage.Current; }
public StreamSocketListenerWrapper( WiFiDirectServiceManager manager, StreamSocketListener streamSocketListener, SessionWrapper session ) { this.streamSocketListener = streamSocketListener; this.session = session; this.manager = manager; this.streamSocketListener.ConnectionReceived += OnConnectionReceived; }
public SessionWrapper( WiFiDirectServiceSession session, WiFiDirectServiceManager manager) { this.session = session; this.manager = manager; this.session.SessionStatusChanged += OnSessionStatusChanged; this.session.RemotePortAdded += OnRemotePortAdded; }
public DiscoveredDeviceWrapper( DeviceInformation deviceInfo, WiFiDirectServiceManager manager ) { this.deviceInfo = deviceInfo; this.manager = manager; ParseProperties(); }
public SocketWrapper( WiFiDirectServiceManager manager, StreamSocket streamSocket = null, DatagramSocket datagramSocket = null) { this.streamSocket = streamSocket; this.datagramSocket = datagramSocket; this.manager = manager; if (streamSocket == null && datagramSocket == null) { throw new Exception("Bad SocketWrapper parameters, must provide a TCP or UDP socket"); } else if (streamSocket != null && datagramSocket != null) { throw new Exception("Bad SocketWrapper parameters, got both TCP and UDP socket, expected only one"); } else if (streamSocket != null) { reader = new DataReader(streamSocket.InputStream); writer = new DataWriter(streamSocket.OutputStream); } else { datagramSocket.MessageReceived += OnUDPMessageReceived; writer = new DataWriter(datagramSocket.OutputStream); } if (reader != null) { reader.UnicodeEncoding = UnicodeEncoding.Utf8; reader.ByteOrder = ByteOrder.LittleEndian; } writer.UnicodeEncoding = UnicodeEncoding.Utf8; writer.ByteOrder = ByteOrder.LittleEndian; }