public async static Task Init(string name) { if (uiThreadDispatcher == null) uiThreadDispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher; myName = name; Peers = new ObservableCollection<Peer>(); preSendRegistrations = new Dictionary<string, PreSendRequest>(); preSendRegistrationsNoCrypt = new Dictionary<string, PreSendRequestNoCrypt>(); listenerSocket = new TCPSocket(); listenerSocket.ConnectionReceived += requestReceived; initializeHandlerMap(); await listenerSocket.StartListening("32102"); if(!(await DataStorage.GetStoredItemAsync("Peers")==null)) { Peer[] newPeers = JSONHandling.ParseJSONResponse<Peer[]>(await DataStorage.GetStoredItemAsync("Peers")); for(int i=0;i<newPeers.Length;i++) Peers.Add(newPeers[i]); } RefreshPeerMap(); await MulticastDiscovery.StartMulticastResponder(myName); MulticastDiscovery.DeviceDiscovered += newPeerDiscovered; }
private async static Task runDiscoveryServer() { echoListener = new TCPSocket(); echoListener.ConnectionReceived += deviceDiscovered; await echoListener.StartListening(DEFAULT_DISCOVERY_PORT); }