android wifi p2p:对等发现过滤 [英] android wifi p2p : peers discovery filtering

查看:64
本文介绍了android wifi p2p:对等发现过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在android应用程序中实现wifi p2P(直接wifi),以便在客户端之间共享小文件.我正在关注这些非常不错的教程: http://developer.android.com/guide/topics/connectivity/wifip2p.html http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

I'm implementing the wifi p2P (direct wifi) in my android application, in order to share small files between clients. I'm following these pretty good tutorials: http://developer.android.com/guide/topics/connectivity/wifip2p.html http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

我现在可以发现同伴并连接到他们.

I can now discover peers and connect to them.

我想知道是否有一种方法可以过滤发现的对等体.我想做的第一件事是仅显示正在使用同一应用程序的对等方.确实,当前我的应用程序向我显示了所有同龄人(电话,平板电脑,具有直接wifi的打印机).我认为,让用户仅拥有兼容的对等方(也使用该应用程序的对等方)会更容易.

I'd like to know if there is a way to filter the discovered peers. The first thing I'd like is to show only the peers who are using the same application. Indeed, currently my application show me all peers (phones, tablets, printers with direct wifi). I think it would be easier for the user to only have the compatible peers (peers also using the application).

如果这项工作有效,我想改善这一点,只向接受共享文件的同伴显示(客户端可以接收文件或/和共享自己激活的文件)

If this work, I'd like to improve this and only show peers who ave accepted to share their files (a client can receive files or/and share their own files if he had activated it)

那么,可以进行这些类型的对等过滤吗?

So, is it possible to do these types of peer filtering?

谢谢.

推荐答案

有一种方法可以实现这一目标...

There is a way to achieve this ...

向您的应用程序添加网络服务发现(NSD)可使您的用户识别局域网中支持您应用程序请求的服务的其他设备.这对于文件共享或多人游戏等各种点对点应用程序很有用.

Adding Network Service Discovery (NSD) to your app allows your users to identify other devices on the local network that support the services your app requests. This is useful for a variety of peer-to-peer applications such as file sharing or multi-player gaming.

首先您需要做

1.在网络上注册您的服务

2.发现网络上的服务

3.连接到网络上的服务

4.在应用程序关闭时注销服务

此处.

因此,使用NSD时,您的应用只会看到支持您应用所请求的服务的设备,不是吗.

So using NSD your app will only see devices that supports the services your app requests, cool isn't it..?

如果我为第二部分提出一些明智的逻辑,我会尽快回复你.

I will get back to you if I come up with some intelligent logic for the second part.

这篇关于android wifi p2p:对等发现过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆