小编fin*_*nss的帖子

Is the value of an Android phone's radio type always GSM, LTE, CDMA or WCDMA?

I'm creating an app that uses Google's Geolocation API, as documented here.

As part of the POST request I need to send to their API, I need to include The mobile radio type, radioType. The question of how to receive that has already been asked and answered here.

My question is as follows:

telephoneManager.getNetworkType()我显然应该使用的函数返回 18 个值之一,在此处记录为常量。

这是否意味着radioTypeGoogle 的地理定位 API 所描述的真的可以是 18 个不同的值?因此,如果事实证明我的无线电类型不是他们支持的四种类型(GSM、LTE、CDMA 或 WCDMA)之一,那么我只是运气不好,将不得不因不包括radioType在我的请求中而损失准确性?

我有一种感觉,我正在混淆这些术语radio typenetwork …

java android google-api radio

1
推荐指数
1
解决办法
731
查看次数

ReactJS客户端和flask-socketio服务器之间的WebSocket连接无法打开

在我的项目中,我正在使用带有RESTful API的React前端和Flask服务器。基本功能是前端从服务器获取数据并显示它。这可以正常工作,但是我认为我可以通过使服务器每当服务器从其他地方接收到新数据时自动重新获取客户端来进行改进。我可以使用轮询并仅在一定间隔内触发获取请求,但这似乎是WebSockets的完美用例。因此,我正在尝试在服务器和客户端之间实现Websocket连接,当某些事件发生时,服务器会将消息发送到客户端。

我的服务器是用Flask用python编写的,使用特定于Flask的websocket库似乎是一个好主意。我最终使用了flask-socketio,但是在使其工作时遇到了问题。我的服务器的相关部分如下:

from flask_socketio import SocketIO, emit

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

... # Server functionality for receiving and storing data from elsewhere, not related to the websocket

# Handle the webapp connecting to the websocket
@socketio.on('connect')
def test_connect():
    print('someone connected to websocket')
    emit('responseMessage', {'data': 'Connected! ayy'})


# Handle the webapp connecting to the websocket, including namespace for testing
@socketio.on('connect', namespace='/devices')
def test_connect2():
    print('someone connected to websocket!')
    emit('responseMessage', {'data': 'Connected! ayy'})


# Handle …
Run Code Online (Sandbox Code Playgroud)

javascript python websocket reactjs flask-socketio

1
推荐指数
1
解决办法
2374
查看次数